Skip to main content

Deploying contracts on validator

Deploying contracts on validators is suitable for developers who are concerned about privacy and security. Saving the contract code yourself will not risk leakage or loss. The deployment method of ERC20 and ERC721 codes is the same, with only minor differences.

Create contract documents​

  1. Start DO program,it will generate a contract folder at the same level as the program.
./don_v0.x.x_devnet -m             
  1. Open the Remix IDE to deploy the contract code,and copy the contract binary code with Bytecode button. image
  2. Create a text file named contract in the contract folder,Paste the copied contract binary code into the created file. image

image

  1. Click the ABI button to copy the ABI code and paste it into the abi.json file.
  • source.sol is the program source code,Store the original Solidity code.
  • abi.json is the contract ABI used for the DO block explorer to parse contract information.
tips:

If the ABI is not provided, the DO block explorer will not be able to parse the output information of contract execution.

DO validator deployment contract​

  1. Menu mode startup DO node, press 8 to deploy the contract. image
  2. Enter the corresponding information content according to the prompt.
  • Account of the deployer
  • Contract type and Contract name
  • Contract language type and language version
  • Contract standard(Not required). But if this item is not provided, the block browser will not be able to display contract execution information
  • Logo url. This link address is a picture resource address, used to display the token icon on the block browser.
  1. Enter 0 to read the contract-related information stored in the contract folder. image

  2. Enter the compiler version used to compile the contract.

    image

  3. Continue entering 0 to read the remaining contract-related information, and finally read the contract binary code. image

    The content information of the successfully read file will be displayed on the command-line

  4. Copy the initial values of the constructor function using the Parameters button.Paste into the command-line to complete the deployment.

    image

image

After deploying the smart contract, you will get two addresses for the contract image

  • ContractAddress and EvmAddress.
    • ContractAddress is used for regular transaction behaviors like DO transfers.
    • EvmAddress is used to interact with the contract, it as a parameter when calling contract functions.

DO validator call contract​

  1. Start DO program, enter 9 to access the contract execution function. image

  2. Enter the corresponding information content according to the prompt.

    • the account executing the contract,
    • the account that deployed the contract
    • the transaction hash generated when deploying the contract
  3. Click Calldata and copy the args and paste it into the command-line to execute the contract.

    image

tips:

The parameter value be filled in with the EVMAddress.
The addresses involved in contract input parameters are all filled in with EvmAddress.

  1. Return to the program command-line and input the copied input data.

    image

  2. Enter the tip you want to pay the contract deployer, and the gas fee for calling the contract on the DO network.

    image

In the contract method call, the method that needs to be uploaded to the chain, such as the token transfer methods(transfer/transferFrom/mint/burn/approve), the DO network gas fee cannot be empty, which is used for transaction packaging and verification. No need for on-chain methods, such as the balance query methods(totalSupply/balanceOf/name/decimals), the gas fee for the DO network can be empty.