[Framework Tutorial for Wanchain #1] - How to run and prepare Wanchain test node for back-end integration

[Framework Tutorial for Wanchain #1] - How to run and prepare Wanchain test node for back-end integration

The goal of this Wanchain tutorial series is to show how the 0xcert Framework can be used with the Wanchain blockchain for building a dapp, as well as creating and managing non-fungible tokens.

⚠️ Prefer building on Ethereum? This tutorial should help.


Before we begin

In this tutorial series, you will learn:

  1. How to set up a Wanchain test node (gwan)
  2. How to create a Wanchain wallet and obtain test WAN tokens
  3. How to set up Express server with TypeScript
  4. How to connect Wanchain with the 0xcert Framework
  5. How to use the 0xcert Framework for back-end
  6. How to set up a simple front-end for testing

At the end of this tutorial series, you will be able to deploy, create, transfer, and query for information about non-fungible tokens on the Wanchain network.

To achieve this, we are using the following technologies:

  • Wanchain testnet
  • TypeScript
  • Node.js
  • Express.js
  • 0xcert Framework
  • jQuery

It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.

All the code used for examples can be found on GitHub with additional functions and explanations.

In this episode, we will accomplish the following:

  1. Set up a Wanchain test node (gwan)
  2. Create a Wanchain wallet and obtain test WAN tokens

Build your dapp on Wanchain


1. Run the Wanchain node

Wanchain is a fork of the Ethereum blockchain, so the basics are the same as for Ethereum.

First, we need to download the node software here. Since this tutorial was done using a Mac computer, we download gwan-mac-amd64-2.0.0-beta-c9bb9922.tar.gz (the latest version as of the time of writing this tutorial). This is the most recent Wanchain POS testnet node.

For mainnet, you need to install the previous 1.0.9 version (the latest as of our writing)

Now, we proceed to unzip the file, open terminal, and move to the folder location. We run the following command:

./gwan console --testnet --rpc --rpcaddr "localhost" --rpcport "8545" --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal"

This initiates the Wanchain testnet node, which will be available at localhost:8545. By running it, a console will open up, and different extensions will become available for use. It will take a while for the node to update so you could take a 30 min break ... ⏳ Well, not really, since you can just let the node run and sync, as we proceed with the tutorial, and we'll come back to it later.

Here is how it looks like when the node starts syncing the proof of stake:

⚠️ Note: If you already had a previous testnet node installed and you updated it to the 2.0.0 beta version, there is a chance you will run into problems when syncing. In that case, remove all the chain data you had previously synced and run clean sync from the start.

2. Create a new Wanchain account (wallet)

In our newly open node console, we can create a new wallet for our project. We do this by writing

personal.newAccount()

into the console. This will prompt us to enter a passphrase. Choose a strong passphrase, write it down, and save it securely. The resulting hash is our public key/wallet, and you should copy it for later use.

Having a wallet is great and all, but we need to acquire some test WAN tokens before we can start playing with it. An excellent source for that is Wanchain faucet which uses social proof to prevent spam. That means you will need to post the hash copied from above to Twitter/Facebook or Google Plus and paste the public link to the website to get the test WAN tokens.

To check the Wanchain testnet and to see if you got the test WANs, go ahead and open their Testnet Block Explorer, and insert the address into the search box. It may take a minute or so for the WANs to appear.


What comes next?

Now that you have created a new Wanchain account and acquired some test WAN tokens, you should be ready to start making JSON-RPC calls or use the 0xcert Framework to do the dirty work for you.

Start building on Wanchain

The Framework is freely available on our GitHub and comes with a thorough documentation. Feel free to use it for you next dapp and feel free to ask for assistance from our devs in the 0xcert Gitter chat.

⬇️Check other tutorial episodes, too⬇️

Framework tutorial for Wanchain #2: Set up Express server with TypeScript for dapp back-end
Framework tutorial for Wanchain #3: Deploy asset ledger
Framework tutorial for Wanchain #4: Create new assets
Framework tutorial for Wanchain #5: Transfer assets
Framework tutorial for Wanchain #6: Atomic operations in asset exchange on Wanchain

Newsletter