Skip to content

Smart Contract Verification

This guide explains how to verify smart contracts on RISE using Hardhat and Foundry.

Using Hardhat

1. Install Dependencies

bash
# Using npm
npm install --save-dev hardhat @nomicfoundation/hardhat-verify

# Using yarn
yarn add --dev hardhat @nomicfoundation/hardhat-verify

2. Configure Hardhat

Add this to your hardhat.config.js or hardhat.config.ts:

javascript
require("@nomicfoundation/hardhat-verify");

module.exports = {
  solidity: "0.8.24",
  networks: {
    'rise': {
      url: [process.env.RPC_URL],
      accounts: [process.env.PRIVATE_KEY],
    },
  },
  etherscan: {
    apiKey: {
      'rise': "abc", // Any non-empty string works for Blockscout
    },
    customChains: [
      {
        network: "rise",
        chainId: 11155931,
        urls: {
          apiURL: "https://testnet-explorer.riselabs.xyz/api",
          browserURL: "https://testnet-explorer.riselabs.xyz/",
        },
      },
    ],
  },
};

3. Deploy and Verify

bash
# Deploy
npx hardhat deploy --network rise

# Verify
npx hardhat verify --network rise <DEPLOYED_CONTRACT_ADDRESS> "Constructor arg1" "Constructor arg2"

# Force verification if needed
npx hardhat verify --network rise <DEPLOYED_CONTRACT_ADDRESS> "Constructor args" --force

Using Foundry

1. Install Foundry

bash
curl -L https://foundry.paradigm.xyz | bash
foundryup

2. Configure Foundry

Add to your foundry.toml:

toml
[rpc]
url = RPC_URL

[verification]
verifier = "blockscout"
verifier-url = "https://testnet-explorer.riselabs.xyz/api/"

3. Deploy and Verify

bash
# Deploy and verify in one step
forge create \
  --rpc-url <RPC_URL> \
  --private-key $PRIVATE_KEY \
  <CONTRACT_FILE>:<CONTRACT_NAME> \
  --verify \
  --verifier blockscout \
  --verifier-url https://testnet-explorer.riselabs.xyz/api/

# Verify existing contract
forge verify-contract \
  --rpc-url <RPC_URL> \
  <DEPLOYED_CONTRACT_ADDRESS> \
  <CONTRACT_FILE>:<CONTRACT_NAME> \
  --verifier blockscout \
  --verifier-url https://testnet-explorer.riselabs.xyz/api/

Important Notes

  • Blockscout ignores constructor arguments during verification, but you must still include them
  • Use --force flag to re-upload sources in case of partial verification
  • Store private keys in environment variables, never in source code

Additional Resources