Verifying Smart Contracts
Scroll Alpha Testnet is now deprecated.
Please visit our new documentation for the Scroll Sepolia Testnet at https://docs.scroll.io/
After deploying your smart contracts, it's important to verify your code on our block explorer. This can be done in an automated way using your developer tooling or using Blockscout's Web UI.
Our Blockscout instance currently has inconsistent behavior in verifying contracts with Foundry. We're working on a fix, along with other stability improvements. Don't hesitate to come ask for help on Discord though.
Using Developer Tools
Most smart contract tooling has plugins for verifying your contracts easily on Etherscan. Blockscout supports Etherscan's contract verification APIs, and it's straight forward to use these tools with the Scroll Alpha Testnet.
Hardhat
First, modify hardhat.config.ts
to point to Scroll's RPC and blockscout.scroll.io/api
. A dummy apyKey
value is required, but anything works for its value.
Now you can verify the smart contract by running the following command.
For example, this how a smart contract that receives two uint parameters in the constructor would look like.
You may receive an error stating etherscan.apiKey.trim is not a function
. If so, you need to update @nomiclabs/hardhat-etherscan
to be able to support custom chains. Try running npm update @nomiclabs/hardhat-etherscan
Foundry
When using Foundry, the verify-contract
helps us verifying contracts.
For example, this what verifying a smart contract that receives two uint
parameters in the constructor looks like:
Please note that certain issues have been reported when executing verifying Smart Contracts from Foundry. In such cases, we recommend trying an alternative method as described on the foundry issues page.
Truffle
To verify contracts with Truffle, first install the truffle-plugin-verify
plugin.
Then, enable the plugin and connect Scroll's Alpha Testnet using the RPC URL and Blockscout verification API.
After migrating our smart contract, we can verify it.
Using the Blockscout Web UI
Shorter contracts can be verified using Blockscout's Web UI. To do so, combine all your Solidity code into one single file, including all the imported libraries. Then, lookup the deployed contract on on Blockscout, then visit the "Code" tab and select "Verify & Publish". Follow the instructions to submit your code.
For a more in-depth guide, see Blockscount's official documentation on Verifying a Smart Contract.
Last updated
Was this helpful?