mud verify
This command uploads the source code for the deployed contracts to a public repository, such as a block explorer. The repository then compiles the source code and verifies that the compiled version is identical to what is deployed onchain.
Using the command
-
Before you run
mud verifyyou need to create a Foundry profile (opens in a new tab). Change to thepackages/contractdirectory and editfoundry.tomlto add a profile with theeth_rpc_urlfor your network (if needed). For example, add these lines to add Holesky.[profile.holesky] eth_rpc_url = "https://ethereum-holesky.publicnode.com"Note that this blockchain has to be supported by the verifier.
-
If using Blockscout, you need to specify the API key:
export ETHERSCAN_API_KEY=<value goes here> -
Run the command.
pnpm mud verify --worldAddress <address here> --verifier <verifier> --profle <profile>These are the command line options you can specify on
mud verify:Option Meaning Type Default value --worldAddressVerify the contracts of the World at the given address string none, error if unspecified --versionShow version number boolean false--configPathPath to the config file string mud.config.ts--verifierThe verifier to use ( sourcify, orblockscout)string --verifierUrlURL to use to access the verifier's API string depends on the verifier used --profileThe foundry profile to use string local--srcDirSource directory string Foundry srcdirectoryNote that it takes block explorers some time to process new contracts. You should wait 5-10 minutes past deployment before you verify the contract on Etherscan and/or Blockscout.
Examples
-
To verify the world at that address on Holesky (after adding the profile to
foundry.toml) on sourcify (opens in a new tab):WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2 pnpm mud verify --profile holesky --worldAddress $WORLD_ADDRESS --verifier sourcify -
To verify on Holesky on Blockscout (opens in a new tab):
WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2 export ETHERSCAN_API_KEY= ** blockscout API key goes here ** pnpm mud verify --profile holesky --worldAddress $WORLD_ADDRESS --verifier blockscout --verifier-url 'https://eth-holesky.blockscout.com/api?'