Code Monkey home page Code Monkey logo

erc20-smart-contract's Introduction

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

erc20-smart-contract's People

Contributors

mauricinhomorales avatar

Watchers

Alex Rozgo avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.