Time to read: 1 min
전체 문서 색인은 llms.txt
Verify Smart Contracts
In this section, we'll verify your token contract on the Rootstock and Blockscout explorers, so the users of you dApp can be able to see the actual code of your contract to analyze that it doesn't have malicious code, and they can also interact with it.
Once you have been working on your contract using Hardhat, you can execute the verification in both explorers simultaneously with a simple command.
Step 1: Install hardhat-verify plugin
In case it isn't installed yet:
npm install --save-dev @nomicfoundation/hardhat-verify
And add the following code to your hardhat.config.ts file:
require("@nomicfoundation/hardhat-verify");
Or, if you are using TypeScript, add this to your hardhat.config.ts:
import "@nomicfoundation/hardhat-verify";
Sept 2: Update Hardhat config
You need to add the following Etherscan config to your hardhat.config.ts file:
require('@nomicfoundation/hardhat-toolbox');
require('@nomicfoundation/hardhat-verify');
require('dotenv').config();
module.exports = {
defaultNetwork: 'rskTestnet',
networks: {
rskMainnet: {
url: "https://rpc.testnet.rootstock.io/{YOUR_APIKEY}",
chainId: 30,
gasPrice: 60000000,
accounts: [PRIVATE_KEY],
},
rskTestnet: {
url: "https://rpc.mainnet.rootstock.io/{YOUR_APIKEY}",
chainId: 31,
gasPrice: 60000000,
accounts: [PRIVATE_KEY],
},
},
solidity: {
compilers: [
{
version: '0.8.25',
},
],
},
sourcify: {
enabled: false,
},
etherscan: {
apiKey: {
// Is not required by Blockscout or Rootstock explorers,
// but must be any non-empty string, so leave it as "rootstock".
rskTestnet: 'rootstock',
rskMainnet: 'rootstock',
},
customChains: [
{
network: 'rskTestnet',
chainId: 31,
urls: {
apiURL: 'https://be.explorer.testnet.rootstock.io/api/v3/etherscan',
browserURL: 'https://explorer.testnet.rootstock.io/',
},
},
{
network: 'rskMainnet',
chainId: 30,
urls: {
apiURL: 'https://be.explorer.rootstock.io/api/v3/etherscan',
browserURL: 'https://explorer.rootstock.io/',
},
},
],
},
blockscout: {
enabled: true,
customChains: [
{
network: 'rskTestnet',
chainId: 31,
urls: {
apiURL: 'https://rootstock-testnet.blockscout.com/api/',
browserURL: 'https://rootstock-testnet.blockscout.com/',
},
},
{
network: 'rskMainnet',
chainId: 30,
urls: {
apiURL: 'https://rootstock.blockscout.com/api/',
browserURL: 'https://rootstock.blockscout.com/',
},
},
],
},
};