ERC20 Token Workshop

Recording on Youtube:

 

Dial in Information is at: https://casperlabs.atlassian.net/wiki/spaces/REL/pages/136544674/Weekly%2BWorkshops%2BHome

Participants

 

  • @Medha Parlikar

  • @Ashok Ranadive (Unlicensed)

  • @Tom Vasile (Deactivated)

 

 

During this workshop, we will demonstrate the use of the example ERC20 Token contract. We will deploy the contract to DevNet, and then we will use scripts to interact with the contract on the CL Blockchain.

Goals

  • Learn how to work with the ERC20 example contract.

  • Install the client - version 0.11

  • Build the contracts

  • Deploy to DevNet

  • Check account balances in Clarity

 

  • We will record the session.

Step by Step Plan

  1. Clone the repository on your machine - the code is presently in a branch.

git clone -b dev https://github.com/CasperLabs/CasperLabs.git

2. Install the CasperLabs client using brew, apt, docker or tarball ….

3. Compile contracts

cd CasperLabs cd execution-engine make setup make build-contract-rs/erc20-smart-contract

4. Fund accounts on DevNet - you can also create new accounts for the test as well. Make sure that all the keys you plan on using have been funded.

Create 3 keys - Key1, Key2, Key3 - and fund Key1 and Key2 by using https://clarity.casperlabs.io.

5. Export your public and private keys to make the commands easier. Export the information for Key1

export PRIV="path_to_private_key_for_Key1 export PUB="public_key_string_from_clarity"

If you are using the Python client, you can skip this step. Otherwise, export the location of the client.

 

Navigate to the scripts directory - there are shell scripts here that make things easier.

There is a script called erc20.sh in the scripts directory. To see all the commands it supports run

 

Now deploy the ERC20 smart contract & specify the token supply

This step creates your initial token supply & the token contract in your account.

Now let’s take a look at GraphQL and confirm that we can see the token contract in our account. From https://clarity.casperlabs.io, Log in and select the GraphQL console from the home page. Create a new tab. Have the hash of the block containing your deployment (or the latest block hash) and the Base16 public key of key1. Enter this query:

Under ‘namedKeys’ you should see 2 names - ‘erc20_proxy’ and ‘test-token’

 

Next we can check the balance in the token contract.

This will return the same number as the supply amount provided during the deploy command.

Next we can perform a token transfer to key2

Now we will check the balance at Key2

You should see the balance of Key2 as the amount you transferred.

Next we will authorize Key2 to transfer some amount of token

This will set the amount that Key2 is authorized to transfer.

Next we will use Key2 to transfer token to Key3. Make sure that Key2 is funded with tokens from the faucet.

Then verify the balance at Key3

It is also possible to purchase more token using the native CLX token

Now check the balance, and do the math!

Software Version (GitHash)

Docker tag: dev

CasperLabs Client 0.11.0 (5777274434bf8cb676c43b0a0ca28f4e015c683e)

What you need to know:

  • The token contract has a default name ‘test-token’ - it’s possible to name the token something different if you want to do so.

Notes:

Title

Description

Notes

Title

Description

Notes

Verify pre-requisites

Check that everyone has managed to get through the setup.

Does everyone have keys in Clarity?

Has everyone cloned the repository and built the contracts?

Does everyone have the client installed? What is the version number for the Client?

 

 

 

Outcome:

  • Folks need to make sure they are running the latest version of Ubuntu.

 

Action items

For Help - go to Discord: https://discord.gg/mpZ9AYD

Decisions

  •