Skip to main content

Prerequisites

  • A deployed contract on Plasma testnet. See deploy a contract if you haven’t deployed one yet.
  • Your contract’s source code and compilation settings.
  • Constructor arguments used during deployment (if any).
The Plasma block explorer (plasmascan.to) serves an Etherscan-compatible verification API. The examples below use that API directly — no third-party account is required to submit a verification.

Example Contracts

We’ll use two example contracts to demonstrate both simple and complex constructor arguments:

Simple Contract

A basic data storage contract that demonstrates fundamental smart contract concepts.

Complex Contract

A more sophisticated vault system for managing token deposits with configurable parameters.

Verify with Foundry

Foundry provides the forge verify-contract command for contract verification.
  1. Ensure your foundry.toml includes the verification settings:
  2. Verify the contract. For the SimpleStorage contract with a string constructor argument:
    For the TokenVault contract with multiple constructor arguments:
  3. Check verification status. Foundry will show real-time verification status with the --watch flag. Look for:

Verify with Hardhat

Hardhat offers contract verification through the @nomicfoundation/hardhat-verify plugin.
  1. Update your hardhat.config.js to include verification settings:
  2. Verify the contract. For the simple contract:
    For contracts with multiple constructor arguments, create a verification script scripts/verify.js:
  3. Run the verification script:

Automated Verification During Deployment

You can also verify contracts automatically during deployment by adding verification to your deployment script:

Verify with Ethers.js

Ethers.js requires manual API calls to the block explorer for verification. This approach gives you full control over the verification process.
  1. Install the required dependencies:
  2. Create verification script verify-ethers.js:
  3. Encode constructor arguments. For complex constructor arguments, you need to ABI encode them. You can use Foundry’s cast tool:
  4. Finally, run the verification:

Check Verification Status

After verification, you can check if it was successful:

On Block Explorer

  1. Visit Plasma testnet explorer.
  2. Search for your contract address.
  3. Look for a green checkmark next to “Contract” tab.
  4. Click the “Contract” tab to view the verified source code.

Programmatically

  1. Create a status check script check-verification.js:

Alternative Methods

While block explorers are the most common verification method, you can also use:

Sourcify

Sourcify provides decentralised contract verification:

Tenderly

Tenderly offers verification as part of their debugging platform. See their documentation for details.

Contract Flattening

For contracts with imports or libraries, you may need to flatten your contract into a single file before verification. Popular tools include: For complex projects with external libraries, see the Hardhat verification documentation for advanced configuration options.

Troubleshooting

Constructor Argument Mismatch

Double-check your constructor arguments match exactly what was used during deployment. Use cast abi-encode to verify encoding.

Compiler Version Mismatch

Ensure the compiler version in your verification request matches the version used during compilation.

Optimisation Settings Mismatch

Verify that optimisation settings (enabled/disabled and runs count) match your compilation settings.

Already Verified

This means verification was successful previously. Check the block explorer to confirm.

Rate Limiting

Wait a few minutes before retrying. Consider upgrading your API plan if you need higher limits.