ERC20 contract deployment Example#
Let’s take the ERC-20 from solidity by example as a demonstration.
Contract Deployment#
First, open the contract codes for IERC20 and ERC20 in the Remix IDE.
Click on the [Compile xx.sol] option on the right to compile.
Click [Compilation Details] to get the contract attachment information required for deployment, including ABI, metadata, compiler version, and so on.
Record or create a text document to save the necessary auxiliary information for deployment on the host where the erbie program is located. For text files, they can be placed in the default folder specified by the program.
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.
Click [Deploy & run transactions] icon Set token name, total supply, gas limit.
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.
7. 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.
If the deployment is successful, the two account addresses of the contract account will be printed on the screen.
INFO
ContractAddress and EvmAddress. ContractAddress is used for regular ERB money transfer transactions, such as money transfer. EvmAddress is used to interact with the contract, such as Token/NFT transfer.
Contract Execution#
Open the Remix IDE, enter the deployment menu, Click [Deploy] and the deployed contracts will appear in Deployed Contracts.
Unfold the details of contract deployment to see the functions that support external calls.
According to official document,it can be seen that balanceOf is used to obtain the token balance of a specific address.
balanceOf
Returns the account balance of another account with address _owner.
function balanceOf(address _owner) public view returns (uint256 balance)
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.
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.
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.
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.