Skip to main content

ERC-20 Contracts

Let’s take the ERC-20 from solidity by example as a demonstration.

Contract Deployment

  1. First, open the contract codes for IERC20 and ERC20 in the Remix IDE.
  2. Click on the [Compile xx.sol] option on the right to compile.

hex

  1. Click [Compilation Details] to get the contract attachment information required for deployment, including ABI, metadata, compiler version, and so on.

hex

  1. Record or create a text document to save the necessary auxiliary information for deployment on the host where the transformers program is located. For text files, they can be placed in the default folder specified by the program.

img

Tips:

Note: source.sol is the program source code, and abi.json is the contract ABI, which is used by the block explorer to parse the contract information. If the ABI is not provided, the block explorer will not be able to parse the output of the contract execution.

  1. Click [Deploy & run transactions] icon Set token name, total supply, gas limit.

img

  1. Run the program in menu mode, press 8 to deploy the contract, and enter the corresponding auxiliary parameters to complete the deployment of the contract.

img

  1. If the constructed function of the contract needs to pass in parameters, it can be passed in at the last item of deployment.

open the deployment option of Remix IDE, fill in the required parameters in the DEPLOY form, and click Parameters to copy the encoded parameters.

Paste the parameters into the program input box to complete the deployment.

img

  1. If the deployment is successful, the addresses of the contract account will be printed on the screen.

img

Contract Execution

  1. Open the Remix IDE, enter the deployment menu, Click [Deploy] and the deployed contracts will appear in Deployed Contracts.
  2. Unfold the details of contract deployment to see the functions that support external calls.

img

  1. According to official document,it can be seen that balanceOf is used to obtain the token balance of a specific address.

img

  1. Enter the account address that interacts with the contract (a string of 20 byte hexadecimal numbers), and click Calldata to obtain the encoded function parameters. By using this parameter, the token balance of an account can be obtained after executing the contract.

img

  1. Run the node program in menu mode and press 9 to execute the contract. First, enter the account of the Contract Executor, and then enter the account of the Contract Deployer,the transaction hash generated by all contracts deployed by the deployer will be displayed.
9


Addrlist
0x77cd290745066F5D0e3cC29E9061F902EB378913 [default]Please enter your addr:
0x8199787886e29346a9f1206494cb8bD3C0b008Cf
================deployers=========================
deployer: 0x77cd290745066F5D0e3cC29E9061F902EB378913
================deployers=========================
Please enter to addr:
0x8199787886e29346a9f1206494cb8bD3C0b008Cf
================deployed utxo=========================
deployed utxo:4cb93b5b624c99edc6285f44ed3fdbff927ed87b8fea27f4c6985c0f9385f0c4
================deployed utxo=========================
Please enter tx hash:
  1. Copy the transaction hash of the contract to be executed, you can complete the execution of the contract by entering the encoded function parameters obtained in step 4, the tip to be paid to the contract deployer, and the fee to be paid to the contract.
Please input your choice:
9


Addrlist :
0x77cd290745066F5D0e3cC29E9061F902EB378913 [default]
Please enter your addr:
0x77cd290745066F5D0e3cC29E9061F902EB378913
================deployers=========================
deplover: 0x77cd290745066F5D0e3cC29E9061F902EB378913
================deployers=========================
Please enter to addr:
0x9efA1DA5ceAaa3680415279373CEc97f98D0A935
================deployed utxo=========================
deployed utxo:4cb93b5b624c99edc6285f44ed3fdbff927ed87b8fea27f4c6985c0f9385fo
================deployed utxo=========================
Please enter tx hash:
0x4cb93b5b624c99edc6285f44ed3fdbff927ed87b8fea27f4c6985c0f9385f0c4
Please enter args:
0x70a08231000000000000000000000000617f2e2fd72fd9d5503197092ac168c91465e7f21
nput contract tip amount :
1
input contract transfer amount :
0

The above only demonstrates the operation of executing a contract to check an account balance. If you want to perform other operations, you need to be familiar with the functions or methods written in the contract and carry out the corresponding operations.