LogoLogo
HomeExplorer
  • Overview
    • Introduction
    • Ecosystem VC Alliance
  • Research
    • Gravity Litepaper
    • Grevm 2.0 (Gravity EVM)
    • (Archived) Grevm 1.0
  • ECOSYSTEM PROGRAMS
    • Developer Grant Program
    • Community Program: Galactic G
  • Network
    • Gravity Devnet (L1)
    • Gravity Alpha Mainnet & Sepolia Testnet (L2)
    • Gravity Alpha Mainnet (L2) Node Setup
    • Gravity Testnet Sepolia (L2) Node Setup
  • Tokens on Gravity
    • G Token
    • How to Get G
    • How to Get Test Tokens
    • Token Contracts on Gravity
  • Developer Resources
    • Mainnet Contract Addresses
    • Testnet Contract Addresses
  • Verify a Smart Contract
  • Ecosystem Infrastructures
    • Wallets & Exchanges
    • Node Providers
    • Developer Utilities
    • Explorers
    • Cross-chain Interoperability
    • Onramps
    • Oracles
    • Smart Contract Wallets
    • Indexers
    • Data Analytics Platforms
    • Gravity Name Service
  • Community
    • X / Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page

Was this helpful?

Export as PDF

Verify a Smart Contract

Verify your smart contract on Gravity Alpha Mainnet

PreviousTestnet Contract AddressesNextWallets & Exchanges

Last updated 23 days ago

Was this helpful?

&

Blockscout uses the global blockscout verifier (so that similar contracts get automatically verified), it can sometimes be flaky. Please try again a bit later.

For contracts deployed by create2, you may ran into Fail - Unable to verify. You will have to visit the contract address page after deployment first. Then blockscout will fetch it from the RPC and see that it is a contract, then verification should work. Contract address page: https://explorer.gravity.xyz/address/***

For users, you will need to change your hardhat.config.ts to something like the following example:

  etherscan: {
    apiKey: {
      // ...
      // Not required. Can be any non-empty string
      gravity: "abc",
    },
    customChains: [
      // ...
      {
        network: "gravity",
        chainId: 1625,
        urls: {
          apiURL: "https://gscan.xyz/api",
          browserURL: "https://gscan.xyz",
          // For Blockscout
          // apiURL: "https://explorer.gravity.xyz/api",
          // browserURL: "https://explorer.gravity.xyz",
        },
      }
    ],
  },
  networks: {
    // ...
    gravity: {
      url: "https://rpc.gravity.xyz",
      chainId: 1625,
      accounts,
    },
  },
[etherscan]
# Gravity explorer does not require an API key, any non-empty string will do.
# gscan
gravity = { key = "abc", url="https://gscan.xyz/api", chain = 1625 }
# Blockscout
# gravity = { key = "abc", url="https://explorer.gravity.xyz/api", chain = 1625 }

Then you when you run your scripts, you can verify contracts deployed with --verify option.

forge script --chain 1625 script/YOUR_SCRIPT.s.sol:YOUR_SCRIPT --rpc-url $GRAVITY_RPC_URL --broadcast --verify -vvvv

NOTE: If contracts were deployed successfully but verification failed, DO NOT delete the broadcast/ directory. You can resume the verification process by removing the --broadcast option and providing the deployment transaction sender's key like below: (or you can configure it in cast):

forge script --chain 1625 script/YOUR_SCRIPT.s.sol:YOUR_SCRIPT --private-key $PRIVATE_KEY --rpc-url  $GRAVITY_RPC_URL --verify -vvvv

For users, we recommend you to use to deploy your contracts. You will need to configure the foundry.toml file as the following:

Blockscout
GScan
hardhat
foundry
scripts