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.
Be sure to pay attention to the choice of Compile Type and compiler version .
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/
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.
Then choose to verify the contract and fill in the address. (It's really good for Ethereum)
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"