Skip to content

Latest commit

 

History

History
102 lines (67 loc) · 2.69 KB

README.md

File metadata and controls

102 lines (67 loc) · 2.69 KB

Smart contract for ERC20 Token

Steps

Add the rust-src compiler component:

rustup component add rust-src

Install the latest version of cargo-contract:

cargo install --force --locked cargo-contract --version 4.0.2

Verify the installation and explore the commands available by running the following command:

cargo contract --help

Install the substrate-contract-node

cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --tag v0.39.0
 --force --locked

Run the substrate-contract-node

substrate-contracts-node --log info,runtime::contracts=debug 2>&1

Setup

Build the contract

cargo contract build

Instantiate the contract with the node already running

cargo contract instantiate --constructor new --args 100000 --suri //Alice --salt $(date +%s) -x

Smart Contract Commands

Update the --contract parameter corresponding to the contract value obtained when instantiated

Get Commands

total_supply:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message total_supply --suri //Alice --skip-dry-run

balance_of:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message balance_of --args 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY --suri //Alice --skip-dry-run
cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message balance_of --args 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty --suri //Bob --skip-dry-run

allowance:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message allowance --args 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY --suri //Alice --skip-dry-run

Write Commands

transfer:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message transfer --args 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty 1000 --suri //Alice -x

transfer_from:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message transfer_from --args 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty 1000 --suri //Alice -x

approve:

cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message approve --args 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 10000 --suri //Alice -x
cargo contract call --contract 5CvDQFoxW1mMsbqKYHNEeWZysbZ1duVRUF2hNkxV9FhhEsxY --message approve --args 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 10000 --suri //Bob -x