Skip to main content

Verifying Smart Contracts with Truffle Verify

This tutorial includes items from the truffle quickstart docs

Inspired by truffle verify docs

Create a Project

Make sure you have truffle installed:

npm install -g truffle

Create a new directory for your Truffle project:

mkdir MetaCoin
cd MetaCoin

Download ("unbox") the MetaCoin box:

truffle unbox metacoin

Once this operation is completed, you'll now have a project structure with the following items:

  • contracts/: Directory for Solidity contracts
  • migrations/: Directory for scriptable deployment files
  • test/: Directory for test files for testing your application and contracts
  • truffle.js: Truffle configuration file


Before we compile our smart contract, we must set up our environment

Run the following commands:

npm init -y
yarn add @truffle/hdwallet-provider yarn add -D truffle-plugin-verify

Create a .env.json file in your project's root directory:

"mnemonic": "your-wallet-seed-phrase",
"snowtraceApiKey": "your-snowtrace-api-key"

Get your Snowtrace API key here

Configure your truffle-config.js file to the appropriate settings:

* Use this file to configure your truffle project. It's seeded with some
* common settings for different networks and features like migrations,
* compilation and testing. Uncomment the ones you need or modify
* them to suit your project as necessary.
* More information about configuration can be found at:
* To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider)
* to sign your transactions before they're sent to a remote public node. Infura accounts
* are available for free at:
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
* phrase from a file you've .gitignored so it doesn't accidentally become public.

const HDWalletProvider = require("@truffle/hdwallet-provider")

const { snowtraceApiKey, mnemonic } = require("./.env.json")

module.exports = {
* Networks define how you connect to your ethereum client and let you set the
* defaults web3 uses to send transactions. If you don't specify one truffle
* will spin up a development blockchain for you on port 9545 when you
* run `develop` or `test`. You can ask a truffle command to use a specific
* network from the command line, e.g
* $ truffle test --network <network-name>

plugins: ["truffle-plugin-verify"],
api_keys: {
snowtrace: snowtraceApiKey,
networks: {
fuji: {
provider: () =>
new HDWalletProvider(
network_id: 1,
timeoutBlocks: 200,
confirmations: 5,

Network can be configured for Mainnet deployment(see Alternatives)

Run the following command:

truffle compile

Once this operation is completed, your ./build/contracts folder should contain the following items:

  • ConvertLib.json
  • MetaCoin.json
  • Migrations.json


Run the following command:

npx truffle migrate --network fuji

You should see the TX activity in your terminal truffle-verify-txn1



Truffle Verify

Truffle verify allows users to verify contracts from the CLI

Fuji Testnet

Take a look at the Fuji Testnet Explorer here and read more about truffle verify here

If you have issues, contact us on Discord

  1. Run the following command:

    npx truffle run verify ConvertLib MetaCoin --network fuji
  2. Wait for the verification message from the CLI truffle-verify-message1

  3. View the verified contract truffle-verify-view-contract


Configure your truffle-config.js file to the appropriate settings:

module.exports = {
plugins: [
api_keys: {
snowtrace: snowtraceApiKey
networks: {

mainnet: {
provider: () => new HDWalletProvider(mnemonic, ``),
network_id: 1,
timeoutBlocks: 200,
confirmations: 5

Run the following commands:

truffle migrate --network mainnet
truffle verify CovertLib MetaCoin --network mainnet

Thanks for reading 🔺