Skip to main content

Truffle

To verify your contracts, you can use Truffle's verification plugin truffle-plugin-verify.

These steps assume you stored your secret keys in a .env file, which you can read more about here.

note

These instructions verify using Etherscan, which currently does not support Yul. If you would like to verify using Blockscout, please use the API URLs referenced here.

Download the plugin​

In your Truffle project, install the plugin:

npm install -D truffle-plugin-verify

Add the plugin to the truffle-config.js file:

module.exports = {
/* ... rest of truffle-config */

plugins: ["truffle-plugin-verify"],
};

Add your Lineascan API Key​

Then, you'll need to get an Lineascan (Linea instance of Etherscan) key by creating an account at https://lineascan.build/myapikey. Grab your key, and add it to the .env file:

MNEMONIC=YOUR_MNEMONIC_HERE
LINEASCAN_API_KEY=YOUR_API_KEY_HERE

Add the custom chain​

We'll need to add a custom chain:

require("dotenv").config();
const { MNEMONIC, LINEASCAN_API_KEY } = process.env;
// ... rest of truffle-config
module.exports = {
networks: {
linea_mainnet: {
provider: () => {
return new HDWalletProvider(
MNEMONIC,
`https://rpc.goerli.linea.build/`,
);
},
verify: {
apiUrl: "https://api.lineascan.build/api",
apiKey: LINEASCAN_API_KEY,
explorerUrl: "https://lineascan.build/address",
},
network_id: "59144",
},
},
// ... rest of truffle-config
};

Verify the smart contract​

Run the following to verify the most recently deployed contract:

truffle run verify <DEPLOYED_CONTRACT_NAME> --network linea_mainnet

Alternatively, verify a contract at a specific address:

truffle run verify <DEPLOYED_CONTRACT_NAME>@<ADDRESS> --network linea_mainnet

Your output should be similar to the following:

Verifying contracts on lineascan
Verifying Token
Pass - Verified: https://lineascan.build/address/<CONTRACT_ADDRESS>#code
Successfully verified 1 contract(s).
Verifying contracts on sourcify
Sourcify has no support for network linea_mainnet with chain id 59144

You can check that it was verified correctly by navigating to the block explorer and pasting in the deployed contract address.

verified contract