For the complete documentation index, see llms.txt. This page is also available as Markdown.

⚖️Contract Verification

In order to enable users and fellow developers to do their own research, it is imperative that you publish your smart contract code on Cronos Explorer. This is called verifying your contracts.

The new Cronos Explorer supports smart contract verification either through the web interface or programmatically via Hardhat (we recommend to use Hardhat).

Cronos Explorer screenshot

Contract Verification Via Explorer Interface:

For verification via the web interface, visit the following URLs:

After the contract verification is complete, the Cronos Explorer will display details about your smart contract code like shown below.

Cronos Explorer screenshot

Contract Verification Via Explorer API:

Cronos Explorer is powered by Blockscout and supports contract verification via the Blockscout Etherscan-compatible API. This allows you verify contracts programmatically as part of your deployment script, without using the UI.

Step 1: Get an API key

An API key is required to use the verification API.

  1. Register an account at Cronos Explorer Account Registration.

  2. Verify your email address.

  3. Sign in and go to your account dashboard.

  4. Click My API Keys to view your default API key, which is assigned automatically on registration.

Step 2: Prepare your contract details

Before calling the API, gather the following from your deployment:

  • Contract address: the deployed contract address on Cronos EVM.

  • Contract name: the name of the contract (e.g. MyContract).

  • Compiler version: the version used to compile the contract (e.g. 0.8.23).

  • Constructor arguments: ABI-encoded constructor arguments, if any.

  • Standard JSON input: the JSON input used to compile the contract. See the Solidity documentation for the format. For Hardhat projects, the Standard JSON input is in artifacts/build-info/*.json.

Step 3: Submit verification via API

Endpoint

  • Mainnet

  • Testnet

Parameters

  • module (required): set to contract.

  • action (required): set to verifysourcecode.

  • contractname (required): contract name.

  • contractaddress (required): deployed contract address.

  • compilerversion (required): compiler version (e.g. 0.8.23).

  • constructorArguments (optional): ABI-encoded constructor arguments.

  • codeformat (required): set to solidity-standard-json-input.

  • sourceCode (required): the Standard JSON input as a string.

Example

A successful response returns a GUID for checking the verification status:

Check verification status

Possible responses:

  • Pending in queue: the request is still being processed.

  • Pass - Verified: the contract has been verified successfully.

  • Fail - Unable to verify: verification failed. Check your source code and compilation settings.

  • Unknown UID: the GUID was not recognised. Check that you are using the correct GUID from the verification response.

Contract Verification Via Remix and Explorer:

For contracts developed in Remix, developers can follow the steps below to verify them on the Explorer:

  1. Compile the contract.

  2. Download the JSON file under artifacts/build-info/ , and please ensure the file follows this format.

  3. Go to the Explorer Contract Verifier introduced in the previous section, fill in the required information, upload the JSON file and verify it on Cronos Explorer.

Contract Verification Via Foundry:

Foundry Integration

Contract Verification Via Hardhat 3:

Hardhat 3 Integration

Contract Verification Via Hardhat 2:

Hardhat 2 Integration

Last updated

Was this helpful?