How To Develop a DApp on VeChain (II): Setup & Walk Around

Sync: Desktop VeChain DApp environment.

Setup in 3 minutes

> mkdir playgrounds> cd playgrounds/> git clone> cd thor-sync.electron/> node -v # Make sure you have node.js >V10.0.0 installed> npm install # Install dependencies> npm run dev # Boot the Sync in dev mode
Boot up: npm run dev

Poke around: Familiar with Sync

Create a Testing Wallet

Go to wallet panel to view existing wallets.
Create a new wallet for our testing

You can also import your existing wallet of Ethereum into Sync, as well as using a third party generator to create a wallet, like VeChain Address Generator on github.


Fuel the wallet with VTHO

Get free VET/VTHO on test net

Play with Connex.js APIs

Open Developer Tools to visit Connex.
> connex {version: "1.2.0", thor: {…}, vendor: {…}}
thor:{ticker: ƒ, account: ƒ, block: ƒ, …}
vendor:{sign: ƒ, owned: ƒ}

Play with account()

> var acc = connex.thor.account('0xa7a609b928c4eac077d0e5640f3fa650746c4fcf')> acc.get().then(info=>{console.log(info)})Promise {<pending>}
{balance: "0x1b1ae4d6e2ef500000", energy: "0x1b1af7398584067000", hasCode: false}
> parseInt('0x1b1ae4d6e2ef500000') 500000000000000000000> parseInt('0x1b1af7398584067000')500005175000000000000

Play with ticker()

> var t = connex.thor.ticker()
>>{console.log('new block!')})
new block!

Play with call()


> const balanceOfABI = {
'constant': true,
'inputs': [
'name': '_owner',
'type': 'address'
'name': 'balanceOf',
'outputs': [
'name': 'balance',
'type': 'uint256'
'payable': false,
'stateMutability': 'view',
'type': 'function'
> const balanceOfMethod = connex.thor.account('0x0000000000000000000000000000456e65726779').method(balanceOfABI)> const balanceInfo = await'0xa7a609b928c4eac077d0e5640f3fa650746c4fcf')> console.log(balanceInfo)
{data: "0x00000000000000000000000000000000000000000000001b1b428acf29437000", events: Array(0), transfers: Array(0), gasUsed: 870, reverted: false, …}


Passion in computer science.