Verify an EVM Contract
Sai Ops recompiles your Solidity build and compares it with the bytecode at the deployed address. Use the same source files, compiler version, optimizer settings, and library addresses as the original build. Keep the build artifacts from your deployment. The verification request runs off-chain and does not need a wallet private key.
Networks and Access
Section titled “Networks and Access”| Network | Verification API |
|---|---|
Sai L1 (6900) | https://ops-api.sai.fun/public/evm/6900/api |
Sai L1 Testnet (6911) | https://ops-api.sai.fun/public/evm/6911/api |
Submissions require a Sai Ops operator key. Set it as the environment variable SAI_EVM_VERIFY_API_KEY in the shell running the command. ABI, source, and job status lookups are public. A successful verification publishes the submitted source and compiler settings.
Verify with Hardhat 2
Section titled “Verify with Hardhat 2”In your Hardhat 2 project, load the plugin @nomicfoundation/hardhat-verify. Merge these entries into your existing Hardhat config, keeping the compiler settings you used for deployment.
networks: { sai: { url: "https://evm-rpc.nibiru.fi/", chainId: 6900, },},etherscan: { apiKey: { sai: process.env.SAI_EVM_VERIFY_API_KEY ?? "" }, customChains: [{ network: "sai", chainId: 6900, urls: { apiURL: "https://ops-api.sai.fun/public/evm/6900/api", browserURL: "https://ops-api.sai.fun/public/evm/6900", }, }],},Set CONTRACT_ADDRESS to the deployed Sai L1 address and use the source path and contract name from your project.
npx hardhat verify --network sai --contract contracts/Counter.sol:Counter "$CONTRACT_ADDRESS"Append any constructor arguments after the address, in deployment order. Use the project and build that produced the deployed contract. The command also works with bunx hardhat.
Verify with Foundry
Section titled “Verify with Foundry”With Foundry 1.7.1, add this entry to your existing foundry.toml.
[etherscan.sai]chain = 6900key = "${SAI_EVM_VERIFY_API_KEY}"url = "https://ops-api.sai.fun/public/evm/6900/api"browser_url = "https://ops-api.sai.fun/public/evm/6900"Use your Sai L1 deployment address and the source path and contract name from your project.
forge verify-contract "$CONTRACT_ADDRESS" src/Counter.sol:Counter \ --chain 6900 --rpc-url https://evm-rpc.nibiru.fi/ \ --verifier etherscan --verifier-url https://ops-api.sai.fun/public/evm/6900/api \ --watchIf the deployment used constructor arguments, pass their ABI-encoded bytes with --constructor-args.
Query the ABI, Source, or Job Status
Section titled “Query the ABI, Source, or Job Status”Use WNIBI on Sai L1 to try the public lookup.
api=https://ops-api.sai.fun/public/evm/6900/apiaddress=0x0CaCF669f8446BeCA826913a3c6B96aCD4b02a97
curl -fsSG "$api" --data module=contract --data action=getabi \ --data-urlencode "address=$address" | jq -e 'select(.status == "1") | .result | fromjson'
curl -fsSG "$api" --data module=contract --data action=getsourcecode \ --data-urlencode "address=$address" | jq '.result[0]'For getabi, parse the response’s result string as JSON. An unknown or unverified address returns an empty SourceCode field on getsourcecode. For an existing job, poll checkverifystatus on the same chain’s API with module=contract and guid=<job-id>. The response reports Pending in queue, Pass - Verified, or Fail - Unable to verify. Inspect the response envelope as Etherscan-style errors can use HTTP 200.
For typed match evidence and the ABI together, query Sai Ops GraphQL.
curl -fsS https://ops-api.sai.fun/public/graphql \ -H 'Content-Type: application/json' \ --data '{"query":"{ contractVerification(chainId: \"6900\", address: \"0x0CaCF669f8446BeCA826913a3c6B96aCD4b02a97\") { address runtimeMatch creationMatch compilerVersion abi } }"}'A runtime match covers the code currently at the address. An exact runtime match also matches the Solidity compiler metadata. Creation proof separately checks the deployment bytecode when available, and the GraphQL field creationMatch can be null. A proxy proof covers the proxy’s bytecode. To check the implementation’s source, look up its own address. The public GraphQL field contract can return a curated ABI for decoding proxy calls.
Verify on Sai L1 Testnet
Section titled “Verify on Sai L1 Testnet”Hardhat 2
Section titled “Hardhat 2”For a testnet deployment, add the saiTestnet network and verifier to your Hardhat config. Set CONTRACT_ADDRESS to the testnet deployment address.
networks: { saiTestnet: { url: "https://evm-rpc.testnet-2.nibiru.fi", chainId: 6911, },},etherscan: { apiKey: { saiTestnet: process.env.SAI_EVM_VERIFY_API_KEY ?? "" }, customChains: [{ network: "saiTestnet", chainId: 6911, urls: { apiURL: "https://ops-api.sai.fun/public/evm/6911/api", browserURL: "https://ops-api.sai.fun/public/evm/6911", }, }],},npx hardhat verify --network saiTestnet --contract contracts/Counter.sol:Counter "$CONTRACT_ADDRESS"Foundry
Section titled “Foundry”Add the testnet verifier to foundry.toml and use the testnet address for CONTRACT_ADDRESS.
[etherscan.sai_testnet]chain = 6911key = "${SAI_EVM_VERIFY_API_KEY}"url = "https://ops-api.sai.fun/public/evm/6911/api"browser_url = "https://ops-api.sai.fun/public/evm/6911"forge verify-contract "$CONTRACT_ADDRESS" src/Counter.sol:Counter \ --chain 6911 --rpc-url https://evm-rpc.testnet-2.nibiru.fi \ --verifier etherscan --verifier-url https://ops-api.sai.fun/public/evm/6911/api \ --watch