Introduction

This tutorial walks you through the steps to set up a Worldwide Asset eXchange (WAX) test server, establish the WAX currency and transfer some into a test account.

This was tested on Ubuntu 18.04 and takes advantage of the waxdev docker container for some of the tooling.

Starting the server

Start the local server (note this maps ~/wax to the /wax folder in the docker instance and forwards the local port 8888 to the API)

docker run -p 127.0.0.1:8888:8888  -d --name waxdev \
  -v ~/wax:/wax waxteam/dev bash \
  -c "/usr/local/wax-blockchain/bin/keosd --http-server-address=0.0.0.0:5555 & \
    /usr/local/wax-blockchain/bin/nodeos -e -p eosio  --plugin eosio::producer_plugin \
    --plugin eosio::chain_api_plugin  --plugin eosio::http_plugin \ 
    --access-control-allow-origin='*'  --contracts-console \
    --http-validate-host=false  --verbose-http-errors --http-server-address=0.0.0.0:8888"

If you look at the logs for this container it’ll have started up and be creating blocks.

Creating a wallet

Next we need to create a new wallet inside our docker instance. We tell cleos to create the wallet in /wax/wallet knowing that it’ll be saved locally as ~/wax/wallet. Note that we are executing the cleos command inside of our running waxdev container.

I like to use a bash alias to shorten these commands, but they are shown in their full detail here.

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
--wallet-url=http://127.0.0.1:5555 wallet create -f /wax/wallet

Next we need to unlock our wallet using the keys that were saved to ~/wax/wallet

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 wallet open

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 wallet unlock --password `cat ~/wax/wallet`

Remember the unlock command above - you’ll need it if you step away and keosd locks your wallet.

Setting up basic functions

Since this is our local test instance, we need to import the Wax master key so that we can perform network level operations (like giving ourselves money) that otherwise would be impossible. This special hardcoded key is the trick to doing that.

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --wallet-url=http://127.0.0.1:5555 \
  wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

One things that’s interesting about EOS block chains (like Wax) is that the currency itself is implemented with a smart contract. It’s unclear to me why the waxdev docker instance doesn’t come with that preinstalled but, at the time of writing, it doesn’t.

Let’s start by making the eosio.token account, we’ll be referncing the Public Key that corresponds to the master key that we imported above

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

Now we need the code for this contact. The official answer is that you should build it from source, but that’s way to time-consuming so let’s pilfer it from the running production blockchain. These commands grab the .wasm and .abi files from production and save them on the docker shared folder.

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=https://wax.greymass.com \
  get code eosio.token -c /wax/eosio.token.wasm --wasm

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=https://wax.greymass.com \
  get abi eosio.token -f /wax/eosio.token.abi

We can turn around and import these onto our own chain

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 set contract eosio.token /wax eosio.token.wasm \
  eosio.token.abi -p eosio.token@active

Make the first tokens

This command creates 1 BILLION WAX and issues 1 million of them to the eosio account. Note that the 8 decimal points here are important as that actually informs the final divisibility of the token

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 push action eosio.token \
  create '[ "eosio", "1000000000.00000000 WAX"]'   -p eosio.token@active

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 push action eosio.token \
  issue '[ "eosio", "1000000.00000000 WAX", "issuing some tokens" ]' -p eosio@active

Make a test account

We’ll probably need a few such test accounts in the course of our development, here’s how to make one.

We start by creating the priavte key for it,

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos \
  --wallet-url=http://127.0.0.1:5555 wallet create_key

> Created new private key with a public key of: "EOS7axManMCEPGdiMnT737MYaQKZJThVuHJtQ6WQ3ciHsPkZVqrWE"

Your key will hopefully be different from mine, but the private counterpart will be stored in your wallet. We’ll use the key from in the next command to create the test1 account on our local chain.

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 \
  create account eosio test1 EOS7axManMCEPGdiMnT737MYaQKZJThVuHJtQ6WQ3ciHsPkZVqrWE

Now we should be able to transfer the WAX from the eosio account to the test1 account

docker exec -i waxdev /usr/local/wax-blockchain/bin/cleos --url=http://127.0.0.1:8888 \
  --wallet-url=http://127.0.0.1:5555 \
  transfer eosio test1 '1.20000000 WAX' 'dont want to share too much'

Conclusion

At this point we should have a container up and running with the basic pieces needed to transfer WAX tokens between accounts and smart contracts.