Verification on Local Test Chain
To verify contracts on your local Ethereum test chain (e.g. Ganache) you need to add the chain to Sourcify manually.
Before that, if you haven't already done so, run Sourcify locally.
First, find the chainId
of your local chain. For Hardhat network default is 31337
. For Ganache it is 1337
. If you don't know the chain id of your network, you can send the net_version
RPC call and look at the result
field:
$ curl localhost:8545 -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'
{"jsonrpc":"2.0","id":67,"result":"31337"}
Similar to adding EVM chains add the chain to sourcify-chains.ts
.
...
export default {
...
"31337": {
"supported": true
},
...
}
Then add or modify the chain at chains.json
. Note that normally this file should not be edited when adding chains to Sourcify. If the chain id does not exist, add a new chain with the id. If it already exist change the rpc
field to http://localhost:8545
:
[
...
{
"name": "Testnet",
"network": "testnet",
"rpc": ["http://localhost:8545"],
"faucets": [],
"chainId": 31337,
"networkId": 31337,
...
},
...
]
If you'd like to use the UI, add the chain to the ui in constants.ts
:
export const CHAIN_OPTIONS = [
...// add testnet
{ value: "local testnet", label: "local Testnet", id: 31337 },
];
Now you can deploy and verify contracts on the testnet. Don't forget to rebuild the repo for changes to take effect:
npx lerna run build
Start the server
npm run server:start
Start the UI
cd ui
nvm use 10
npm start
Similarly you can test out verification on any chain without changing chains.json
file.