[Contract Development Tools] Contract Open Source and Verification

foreword

After we deploy the contract, we can upload the source code of the contract to the browsers of each chain to open source and verify it. First, it is convenient for front-end and back-end debugging codes, and second, it is convenient for others to view the contract code.

ETH’s contract is recommended to be verified in Remix;
BSC’s contract is recommended to be verified in Hardhat;
OKC’s contract is recommended to be verified in Explorer;

Explorer authentication

Register first in Scan and apply for an API key.

Click Verify and Publish on the browser , and operate according to the configuration.

insert image description here

Be sure to pay attention to the choice of Compile Type and compiler version .

insert image description here
If the constructor has parameters, you need to enter the abi-encode of the parameters in this box, and the following URL can be easily converted.

https://abi.hashex.org/

insert image description here
After that, the authentication is fine, and the authentication of other browsers is similar.

Remix verification

In the Remix plugin repository, activate the Verification plugin.

insert image description here
Then choose to verify the contract and fill in the address. (It's really good for Ethereum)

insert image description here

Hardhat Verification

yarn add @nomiclabs/hardhat-etherscan

Write the API key registered on scan in .env

Add configuration to the outermost layer of hardhat.config.ts:

  etherscan: {
    
    
    apiKey: $API_KEY,
  },

run command

npx hardhat verify --network <network> <DEPLOYED_CONTRACT_ADDRESS> "Constructor argument 1"

Guess you like

Origin blog.csdn.net/weixin_43742184/article/details/124182173