Wanchain Hackathon Handbook San Jose

Similar documents
Wanchain Documentation

Wanchain Documentation

FXY TOKEN SMART CONTRACT AUDIT RESULTS FOR FIXY NETWORK LTD

Secure Token Development and Deployment. Dmitry Khovratovich and Mikhail Vladimirov, University of Luxembourg and ABDK Consulting

Ethereum. Smart Contracts Programming Model

BLOCKCHAIN CADEC Pär Wenåker & Peter Larsson

Learn Blockchain Programming. Ali Dorri

Beerchain. Creating the beer-based cryptocurrency. Yellowpaper version 0.3, 3/11/2018

a new cryptocurrency STK GLOBAL PAYMENTS USER GUIDE USER GUIDE: PARTICIPATING IN IN STK STK TOKEN TOKEN SALE USING SALE MYETHERWALLET

Aion Network. Owner s Manual. The Aion Foundation April User s Manual

OW TO PARTICIPAT HOW TO PARTICIPATE

Populus Documentation

Blockchain-enabled peer-to-peer marketplaces

For further information about the GRID token sale, please visit gridplus.io/token-sale.

NEW TOKEN SWAP INSTRUCTIONS For action after July 23, 2018.

Introduction to Express.js. CSC309 Feb. 6, 2015 Surya Nallu

MCFT: Multi-Class Fungible Token

Hong Kong JavaScript and Node.js. Welcome

SECURITY AUDIT REPORT

FanChain Contract Audit

TABLE OF CONTENTS 1.0 TOKEN SALE SUMMARY INTRODUCTION HOW TO BUY LION HOW TO BUY LION WITH METAMASK

Smart!= Secure - Breaking Ethereum Smart Contracts. Elliot Ward & Jake Humphries

Technical Specifications for Platform Development

Guide to a Successful Wanchain Token Contribution

FLIP Token (FLP) How to Participate in the FLIP Token (FLP) Sale Event. 1 Disclaimer 2. 2 What You Will Need 2

Windows cold wallet managing Linux VPS connected Masternode

NAV Coin NavTech Server Installation and setup instructions

kasko2go Token Contract Audit

Knowledge Platform TOKEN SALE. GUIDELINE (MetaMask & MyEtherWallet)

How Can I See My ENJ? 15. Acquiring Ether (ETH) 16

Technical White Paper of. MOAC Mother of All Chains. June 8 th, 2017

ISSUSE AND FEATURES TO CONSIDER WHEN SELECTING A BLOCKCHAIN SYSTEM. Find us at

Ethereum in Enterprise Context

How to Buy TRVR Tokens

MYETHERWALLET GUIDE 1

Blockchain Frameworks

ICO smart contracts Documentation

CREDITS Web-version 2 Web-version specification CREDITS Desktop Client vs. Web-client What is the CREDITS Wallet? 2 1.

Active Planning Committee John Lindsay, Patent Attorney Tony Schuman, Investment Advisor Todd Russell, Gov t Contract Opportunities


How to buy LIVE Token with Ethereum and Bitcoin step by step

The World s first Public Chain for Decentralized NaaS (Network-as-a-Service)

Muzika Studio now supports Ethereum and Ontology network, and users can choose to login to either Testnet or Mainnet.

GUTS Token Sale Audit

Enjin Coin Yellow Paper

An Analysis of Atomic Swaps on and between Ethereum Blockchains Research Project I

HowtobuyHUMToken. Table of Contents. Beforeproceedingwiththepurchase Pre-saleguideusingMyEtherWallet Pre-saleguideusingMetamask

Privacy based Public Key Infrastructure (PKI) using Smart Contract in Blockchain Technology

Building Applications on the Ethereum Blockchain

CLN CLN TOKEN SALE. How to Participate Using MyEtherWallter

Building Decentralized Applications with Ethereum

Practical Node.js. Building Real-World Scalable Web Apps. Apress* Azat Mardan

HOW TO PARTICIPATE IN VESTARIN PRE-ICO & ICO with ETHERIUM

Contents in Detail. Foreword by Xavier Noria

A practical introduction

Table of contents. Abstract. Disclaimer. Scope. Procedure. AS-IS overview. Audit overview. Conclusion. Appendix A. Automated tools reports 12

Next Paradigm for Decentralized Apps. Table of Contents 1. Introduction 1. Color Spectrum Overview 3. Two-tier Architecture of Color Spectrum 4

Ethereum Consortium Blockchain in Azure Marketplace Christine Avanessians Senior Program Manager

MASTERNODE Setup Guide

Pillar Token Code Review

Gnosis Safe Documentation. Gnosis

DTX Token. Starter guide

LECTURE 2 BLOCKCHAIN TECHNOLOGY EVOLUTION

Introduction to Fabric Composer

ETHEREUM META. Whitepaper 2018/2019. A decentralized token with privacy features. Ethereum Meta team

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

Tutorial 4 Data Persistence in Java

Node.js. Node.js Overview. CS144: Web Applications

TOKEN SWAP FAQ. For action before July 23, 2018.

Brunch Documentation. Release Brunch team

Ethereum Consortium Network Deployments Made Easy Christine Avanessians Senior Program Manager

GENESIS VISION NETWORK

Instruction for creating an Ethereum based wallet and MUH ICO participation

Lecture 10. A2 - will post tonight - due in two weeks

SUN Token Ecosystem Architecture Written by: Sun Token Technical Team Date: September 20, 2018 Version: 1.06

TABLE OF CONTENTS 1.0 TOKEN SALE SUMMARY INTRODUCTION HOW TO BUY LION HOW TO BUY LION WITH METAMASK

Red Hat JBoss Web Server 3.1

Final Presentation Master s Thesis: Identification of Programming Patterns in Solidity

Who wants to be a millionaire? A class in creating your own cryptocurrency

Getting Started With NodeJS Feature Flags

Elphyrecoin (ELPH) a Private, Untraceable, ASIC-Resistant CryptoCurrency Based on CryptoNote

Token Sale. Participation guide

How to Invest in the Gizer Token Sale. A guide for contributing to the Initial Offering of GZR Tokens

Page Total

Tools. SWE 432, Fall Design and Implementation of Software for the Web


Privacy-Enabled NFTs: User-Mintable, Non-Fungible Tokens With Private Off-Chain Data

Unblockable Chains. Is Blockchain the ultimate malicious infrastructure? Omer Zohar

PARTICIPATING IN PODONE s ICO

Securify: Practical Security Analysis of Smart Contracts

Technical Description. Platform SRG community

Smart Contract Security Tips. Ethereum devcon2 Sep Joseph Chow

TangeloHub Documentation

Administration Dashboard Installation Guide SQream Technologies

I. How to Purchase Cryptfunder CFND Tokens

ZILLIQA / ZILIKƏ/ NEXT GEN HIGH-THROUGHPUT BLOCKCHAIN PLATFORM DONG XINSHU, CEO JIA YAOQI, BLOCKCHAIN ZILLIQA.

LOCAL WALLET (COLD WALLET):

Whitepaper The blockchain platform for building decentralized marketplaces

PascalCoin Exchange Integration Guide. Compatible with version 4 of PascalCoin

3rd Party Application Deployment Instructions

Transcription:

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Wanchain Hackathon Handbook San Jose Developing Wanchain Applications & Hackathon Challenge Proposals Presenter: Weijia Zhang, PhD

Contents Blockchain application Ideas Getting Started Wanchain Smart Contracts Wanchain Applications and Hackathon Challenges

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Overview and Application Ideas

Overview of Blockchain Applications

Wanchain Applications for Developers Tools Enhancement Wanchain Explorer Wanchain Wallet Wanchain online wallet Wanchain monitoring data mining and monitoring tools Wanchain Hardware Wallet Good project: A hardware wallet sells at $100 a piece Build USB device with firmware for a private key generation and signing algorithm Writing hardware connector app Link hardware connector with Wanchain wallet

Wanchain Applications for Developers Wanchain smart contracts with private transactions Build smart contract with private transactions Issue ERC token with private transactions Wanchain cross-chain applications Build smart contracts with cross-chain transactions Build cross-chain explorer, wallet, and hosting services

Wanchain Nodes and Applications Topology DATE DATE DATE DATE Explorer Gwan DATE DATE SC Gwan Wallet Gwan Crosschain Apps Gwan DATE DATE DATE DATE

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Getting Started

Running a Wanchain Node Prerequisites 1. Go to: https://golang.org/doc/install 2. Install go-wanchain https://github.com/wanchain/go-wanchain $ git clone https://github.com/wanchain/go-wanchain.git $ cd go-wanchain $ make gwan 3. Run Your Node Example 1 - testnet $ gwan --testnet --rpc --rpccorsdomain "127.0.0.1" --rpcaddr "127.0.0.1" --verbosity=0 console Example 2 - mainnet $ gwan --rpc --rpccorsdomain "http://localhost:<your DAPP PORT>" -- verbosity=0 console

HTTP based JSON-RPC API options: --rpc Enable the HTTP-RPC server --rpcaddr HTTP-RPC server listening interface (default: "localhost") --rpcport HTTP-RPC server listening port (default: 8545) --rpcapi API's offered over the HTTP-RPC interface (default: "eth,net,web3") --rpccorsdomain Comma separated list of domains from which to accept cross origin requests (browser enforced) --ws Enable the WS-RPC server --wsaddr WS-RPC server listening interface (default: "localhost") --wsport WS-RPC server listening port (default: 8546) --wsapi API's offered over the WS-RPC interface (default: "eth,net,web3") --wsorigins Origins from which to accept websockets requests --ipcdisable Disable the IPC-RPC server --ipcapi API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3") --ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)

Interact with blockchain with a JavaScript console: A JavaScript console can be used to use a web3 protocol to interact with the blockchain. Blockchain JavaScript console can be invoked by either attaching to an existing RPC server or through a running node itself. Method 1: gwan attach http://rpc-ip:rpcport Method 2: $ gwan --testnet --rpc --rpccorsdomain 127.0.0.1 --verbosity=0 console The web3 commands are defined by Ethereum foundation. Wanchain extends web3 commands with its unique functions for privacy transactions.

Interact with blockchain by a nodejs script: In order to connect to your blockchain via RPC, make sure your node is running and that you used --rpc flag when starting up your node. We are assuming you are using localhost to run your dapp so you also want to make sure to have the following included in your node startup command --rpccorsdomain 127.0.0.1 Using nodjs script: You need to install web module var Web3 = require('web3'); web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); web3.eth.getcoinbase(function(err,resp){ console.log('coinbase',resp) }); If you ran this on the client, you should see the address of the account

Getting Started Exercises Body Level One Write a hello wanchain program to Get latest block number Accounts Transactions of an account Balance of an account Body Level Two Body Level Three Body Level Four Body Level Five

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Writing Wanchain Smart Contracts

farwesttoken example pragma solidity ^0.4.21; // Abstract contract for the full ERC 20 Token standard contract EIP20Interface { uint256 public totalsupply; function balanceof(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferfrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value);

farwesttoken example: constructor definition contract EIP20 is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256-1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; constructor ( uint256 _initialamount, string _tokenname, uint8 _decimalunits, string _tokensymbol ) public { balances[msg.sender] = _initialamount; totalsupply = _initialamount; name = _tokenname; decimals = _decimalunits; symbol = _tokensymbol; }

farwesttoken example: transfer function definition function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferfrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); return true; }

farwesttoken example: balance etc functions function balanceof(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; }

farwesttoken example: main class definition contract FarwestToken is EIP20 { string public constant name = "FarwestToken"; string public constant symbol = "FWT"; uint8 public constant decimals = 18; uint256 initialsupply = 210000000000 * 10 ** uint256(decimals); address owner; constructor () EIP20 (initialsupply, name, decimals, symbol) public { } owner = msg.sender; function minttoken(address recipient, uint amount) public { require (msg.sender == owner); } balances[recipient] += amount; totalsupply += amount; emit Transfer(0, this, amount); emit Transfer(this, recipient, amount);

farwesttoken example: gateway definition function () public payable { address recipient = msg.sender; uint256 gettokens = 1000 * msg.value; // 1:1000 to get tokens, msg.value is the received ether balances[recipient] += gettokens; balances[owner] -= gettokens; emit Transfer(owner, recipient, gettokens); } owner.transfer(msg.value);

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Compile and Deploy Smart Contract with Remix

Compile and Deploy farwesttoken: Prepare the following A working Wanchain client node, see previous section Remix online or remix standalone IDE A smart contract such as farwesttoken.sol

Compile and Deploy farwesttoken: Go to remix, copy and paste your smart contract code, make static syntax analysis, and compile it Click Details on the right panel of remix, copy all the code of WEB3DEPLOY section from the pop-up Copy the script and run it in gwan console

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Compile and Deploy Smart Contract with Truffle

Install Truffle: Truffle is a command line tool to compile, deploy, and test smart contracts on blockchain. Before installing truffle, you want to install or upgrade the npm to the latest version. To install npm, use the following command: $ sudo apt-get install npm To upgrade npm, use the following command $ sudo npm i -g npm Run npm to install truffle $ sudo npm install -g truffle

Initiate a truffle project for Wanchain Make a truffle directory $ mkdir wanchain-example In the truffle project directory, execute: $ truffle init Once a truffle project is initialized, several directories will be created, including contracts: where the source contracts are supposed to reside migrations: where the deployment scripts are supposed to reside test: where the test files are supposed to reside build: the contract compiled result will be put here, created after running truffle compile or truffle migrate. truffle-config.js: The configuration file provides default setup parameters for the project truffle.js: This provide truffle smart contract parameters

Compile a truffle project for Wanchain In the truffle project directory, execute the command: $ truffle compile If the compilation is successful, a build directory will be created and abi files will be generated under build/contracts/directory. These abi files can then be deployed as smart contract.

Config a Truffle project for Wanchain Setup truffle.js file to specify the network setting etc. module.exports = { networks: { development: { host: 'localhost', port: 8545, network_id: '*', gas: 4000000, gasprice: 180e9, // following address needed to be replaced with unlocked account on gwan node from: '0x8f84573C8BaB4d56FDdB48cc792424E8816908fB' } } } Add deploy script for contract in the directory migrations in the truffle project: Such as the deploy script name is 2_deploy_contracts.js which will deploy the contract PollApp.sol in the contract directory, the script will be as following: var farwesttoken = artifacts.require("./farwesttoken.sol"); module.exports = function(deployer) { deployer.deploy(farwesttoken); };

Start gwan node on local host Run following command in the directory which include gwan $./gwan --rpc --testnet --rpcapi eth,net,admin,personal,wan --verbosity=0 console In the gwan console to unlock a existing wanchain account in gwan node and make sure there are balance in the unlocked account, this account needs to be same with the from address in the file truffle.js

Deploy the smart contract Execute command in the truffle project directory: $ truffle migrate --network development The result will be as following:

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Write a Private Smart Contract

Private token transaction for smart contracts const fs = require('fs'); const assert = require('assert'); const keythereum = require("keythereum"); const secp256k1 = require('secp256k1'); const net = require('net'); const Web3 = require('web3'); const web3 = new Web3(keystore_dir/gwan.ipc', net)) const wanutil = require('wanchain-util'); web3.wan = new wanutil.web3wan(web3) const keystorepath = ***/keystore/'; const stampabi = require('./stamp-abi'); const farwestprivacytokenabi = require('./farwest-privacy-token-abi'); const privacycontractabi = require('./privacy-contract-abi'); const stampsmartcontractaddress = '0x00000000000000000000000000000000000000c8'; const farwestprivacytokencontractaddress = '0xd4A4b87420269ca95ee6F4ea7dd9c1238d8590ED'; const farwestprivacytokencontract = web3.eth.contract(farwestprivacytokenabi).at(farwestprivacytokencontractaddress);

Private token transaction: Step1 - Unlock account try { await promisify(callback => web3.personal.unlockaccount(senderaddress, senderpassword, 99999, callback)); console.log('unlock account successfully.'); } catch (error) { } console.log(error);

Private token transaction: // Step2 - Init privacy token balance let txmintdata = farwestprivacytokencontract.mintprivacytoken.getdata(tokenholderaddress, tokenholderotaaddress, initamount); let inittxparams = {from:senderaddress, to:farwestprivacytokencontractaddress, value:0, data:txmintdata, gas: 4000000}; try { txhash = await promisify(callback => web3.eth.sendtransaction(inittxparams, callback)); console.log ('Init amount for ' + tokenholderaddress + ' is ' + web3.fromwei(initamount)); console.log ('Init asset tx hash is ' + txhash); //Wait unitl the tx be mined await waituntiltxmined (txhash) console.log ('The init privacy aseset tx has been mined.'); } catch (error) { console.log(error); }

Private token transaction: // Step3 - Get the init privacy token by web3 try { ret = await promisify(callback => farwestprivacytokencontract.otabalanceof(tokenholderaddress, callback)); privacytokenbalance = web3.fromwei(web3.todecimal(ret)); console.log ('The privacy balance of ' + tokenholderaddress + ' is ' + privacytokenbalance); assert.equal (privacytokenbalance, web3.fromwei(initamount)); } catch (error) { } console.log(error);

Private token transaction: // Step4 - Buy stamp const stampcontract = web3.eth.contract(stampabi).at(stampsmartcontractaddress); let senderstampotaaddress = wanutil.generateotawaddress(senderwanaddress); let txbuydata = stampcontract.buystamp.getdata(senderstampotaaddress, stampvalue); let buystamptxparams = {from:senderaddress, to:stampsmartcontractaddress, value:stampvalue, data:txbuydata, gas: 4000000} try { txhash = await promisify(callback => web3.eth.sendtransaction(buystamptxparams, callback)); console.log ('Stamp address is ' + senderstampotaaddress); console.log ('Buy stamp tx hash is ' + txhash); //Wait unitl the tx in step5 mined await waituntiltxmined (txhash); console.log ('The buy stamp tx has been mined.'); } catch (error) { console.log(error); }

Private token transaction: // Step5 - Get ring sign data and Send privacy token transaction const stampmixnumber = 3; try { otaset = await promisify(callback => web3.wan.getotamixset(senderstampotaaddress, stampmixnumber, callback)); ringsigndata = getringsigndata (senderaddress, senderpassword, senderstampotaaddress, tokenholderaddress, otaset); combineddata = getcombineddata (recipientwanaddress, ringsigndata); tokenholderprivatekey = '0x' + getotaprivatekey(senderaddress, senderpassword, tokenholderotaaddress).tostring('hex'); privacytokentransaction = { Txtype: '0x01', from:tokenholderaddress, to:farwestprivacytokencontractaddress, value: '0x0', gasprice: '0x2e90edd000', gas: '0x0', data:combineddat; }; console.log (privacytokentransaction); ret = await promisify(callback => web3.wan.sendprivacycxttransaction(privacytokentransaction, tokenholderprivatekey, callback)); console.log ('Send privacy token tx hash is ' + ret); } catch (error) { console.log(error); }

Body Level One Body Level Two Body Level Three Body Level Four Body Level Five Hackathon Challenges

Hackathon Challenges Challenge Name Description Remarks 1 Wanchain Explorer Write a blockchain explorer to browse Wanchain blockchain contents, such as accounts, transactions, blocks etc. Can use a console version or GUI version. Can use nodejs or javascript console to fetch data from Blockchain. 2 Wanchain Smart Contract Write a useful and valuable smart contract that solves a unique and challenging problem. Deploy to Wanchain testnet. 3 Wanchain Online or Light Wallet 4 Wanchain Decentralized Exchange Design and/or implement a light or online Wanchain wallet. The wallet could consider the features of Hardware wallet support, privacy support, and cross-chain support. Design and/or implement a decentralized private exchange center on Wanchain with features similar to etherdelta. Difficulty: Entry Delivery: The project should be delivered with code implementation. Prize: 200 WAN Difficulty: Varies Delivery: Source code, ABI, deployed smart contract. Prize: 300 WAN Difficulty: Medium-High Delivery: You can deliver the project as design only or design and implementation. Prize: 400 WAN Difficulty: High Delivery: You can deliver the project as design only or design and implementation. Prize: 500 WAN

Hackathon Judging Criteria (500 WAN prize example) 1 2 3 4 5 Total Prize: 500 WAN Not Not very Neutral Somewhat Very Score Weight Total WAN Prize Paid Creativity/Uniqueness 5 5 Prize % Paid Min Max Design Thoroughness of Design 5 5 12 100% 15.4 18 500 60% Technical Merit 5 5 85% 12.7 15.3 425 Look and Feel 5 5 70% 10 12.6 350 55% 0.1 9.9 275 Security 5 5 0% 0 0 0 Technical Implementation Wanchain Privacy Features 5 5 Clearness/Organization 5 5 20% 5 Documentation/Commenting 5 5 Project Value Value Proposition of Project 5 5 Value vs. Existing Products 5 5 20% 1 Project Total 18 Total Max 18 Prize % Paid 100% Total Prize 500

Challenge 1: Blockchain Explorer

Challenge 1: Blockchain Explorer

Challenge 1: Blockchain Explorer Wanchain explorer work flow Download gwan from github.com github link : www.wanchain.org Run gwan in ubuntu, windows, or Mac Attach to gwan and use web3 to access blockchain data Visualize blockchain data

Challenge 2: Building a smart contract https://github.com/wanchain/go-wanchain/tree/master/contracts/demo

Challenge 3: Wanchain Wallet (Medium Level) Wanchain Wallet development flow Download wanguiwallet. github link: www.wanchain.org Compile the source code Launch the gui application. It will automatically download the gwan

Challenge 4: A Decentralized Privacy-enabled Exchange High-difficulty Entrepreneurial-level challenge to create a decentralized version of etherdelta. Potential to be sponsored as a WanLabs project. Open-ended challenge to design and/or implement a decentralized privacy-enabled exchange center on Wanchain with features similar to etherdelta.

Wanchain Cross-Chain Applications

Join the conversation Official Website: www.wanchain.org Email:info@wanchain.org Twitter:https://twitter.com/wanchain_org Facebook:https://www.facebook.com/wanchainfoundation/ Slack:wanchain.slack.com Reddit: https://www.reddit.com/r/wanchain/ Telegram: Announcement Channel: https://t.me/wanchainann (Pending your participation!) Chat Group: https://t.me/wanchainchat