Verify a Smart Contract
Verify your smart contract on Gravity Alpha Mainnet
Last updated
Was this helpful?
Verify your smart contract on Gravity Alpha Mainnet
Last updated
Was this helpful?
There are four major ways to verify contracts on OKLink:
You can verify a deployed contract directly through the .
OKLink provides a set of .
Prerequisite: Get an OKLink API Key
Apply for an API key:
Run forge verify-contract
To verify a contract, you need to provide:
The deployed contract address
The contract path and name (e.g., src/MyToken.sol:MyToken
)
The OKLink verify-url
for your target chain
Your OKLink API key
Command format:
Check Verification Status
It is recommended to use the --watch
flag to continuously poll for verification status.
If you didn’t use --watch
, you can manually check the result using:
@okxweb3/hardhat-explorer-verify
PluginThis method uses an official Hardhat plugin provided by OKX. It provides a CLI command (npx hardhat okverify
) to automate contract verification.
1. Install the Plugin
2. Configure hardhat.config.ts
Here is a sample configuration for Gravity Chain:
3. Verify the Contract
After deployment, verify with:
4. Verifying Proxy Contracts
For contracts deployed via TransparentUpgradeableProxy
, use:
If you're using the 897 proxy standard, omit --proxy
and just run the command as normal
etherscan.customChains
for OKLinkYou can also verify contracts using Hardhat's native Etherscan integration by overriding the default verification endpoint.
Configuration Example:
This enables Hardhat’s built-in verify
task to interact with OKLink:
⚠️ You’ll still need to ensure your contract metadata matches what OKLink expects (e.g., compiler version, optimization settings, source flattening if needed).
Then you when you run your scripts, you can verify contracts deployed with --verify
option.
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):
For users, you will need to change your hardhat.config.ts
to something like the following example:
For users, we recommend you to use to deploy your contracts. You will need to configure the foundry.toml
file as the following: