For the complete documentation index, see llms.txt. This page is also available as Markdown.

Verify a contract with Truffle

Who this is for: developers who've deployed a contract with Truffle and want its source code visible and callable on the explorer.

Prerequisites: a contract already deployed. See Deploy a contract with Truffle.

Time: a couple of minutes.

1

1. Install the verification plugin

npm install --save-dev truffle-plugin-verify
2

2. Add it to truffle-config.js

truffle-config.js
module.exports = {
  // ...existing config
  plugins: ["truffle-plugin-verify"],
  api_keys: {
    lumiaBeam: process.env.LUMIA_EXPLORER_API_KEY, // {{TODO: confirm whether an API key is required at all}}
  },
};
3

3. Confirm the verifier backend

4

4. Run verification against your deployed address

npx truffle run verify YourContract@<DEPLOYED_CONTRACT_ADDRESS> --network lumiaBeam

Verify it worked

Open the contract's address on the Beam explorer (see Block explorers). The Contract tab shows your source code and a Read/Write Contract panel once verification succeeds.

Troubleshooting

truffle run verify fails with an API/network error

The explorer API endpoint or key requirement isn't confirmed yet for Lumia. See the TODO above.

"Already verified" but the explorer shows no source

Try again with the exact compiler version and optimizer settings used at deploy time; a mismatch here is the most common cause.

Constructor argument encoding errors

Confirm the contract name after @ in the command matches the artifact name exactly, including case.

Was this helpful?