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
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
Update the --contract parameter corresponding to the contract value obtained when instantiated
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
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