Cronos EVM Docs
  • Getting Started
    • Getting Started
    • Background
    • Architecture
    • Cronos roadmap
  • FOR USERS
    • 💳Crypto.com Card Top Up
    • 🔥Crypto Wallets
    • 🦊MetaMask Configuration
    • 🦁Brave Wallet
    • 🌉Bridges
      • From the Crypto.com App and Exchange
        • From the Crypto.com App
        • From the Crypto.com Exchange
      • IBC (Cronos POS Chain, other Cosmos chains)
        • Cronos Bridge Web App
      • Independent bridges
      • FAQs for Bridge transfers
      • FAQs for transactions from/to centralized exchanges
    • 🚰Testnet Faucet
    • 💡Tips & FAQs
    • 👮Key Principles for Wallet Security
    • GasTracker
  • FOR DAPP DEVELOPERS
    • 💡Founder FAQs
    • 🏅Hacker's Getting Started Resources
    • 📃Smart Contracts
      • Contract Development on Testnet
      • Contract Deployment and Verification
      • Contract Verification Export: Cronoscan To Cronos Explorer
      • Best Practices
      • Token Contract Addresses
    • 💻dApp Creation
      • Free and commercial RPC endpoints
      • Wallet integrations
      • Web3-wallet
      • JSON-RPC methods
      • Address Conversion
      • Swagger Playground
    • ⚙️Dev Tools & Integrations
      • All dev tools & integrations
      • Account Abstraction
      • Band Protocol
      • Banxa
      • GoldRush
      • Cronos Safe
      • Flair
      • Google Bigquery
      • Moralis
      • Pyth
      • Secret Network
      • SubQuery
      • Witnet
    • Crypto.com AI Agent SDK
  • FOR NODE HOSTS
    • Running nodes
      • Cronos Mainnet
        • Quicksync
        • State-sync
        • Public Node Sync
        • KSYNC
        • The "Huygen" upgrade guide (v0.6.* to v0.7.*)
        • The "v0.7.0-hotfix" upgrade guide (v0.7.* to v0.8.*)
        • The "Galileo" upgrade guide (v0.8.* to v1.0.*)
        • The "Titan" upgrade guide (v1.0.* to v1.1.0)
        • The "v1.2" upgrade guide (v1.1.* to v1.2.0)
        • The "v1.3" upgrade guide (v1.2.* to v1.3.0)
        • The "v1.4" Pallene upgrade guide (v1.3.* to v1.4.1)
        • Patching Unlucky & Duplicate Tx
      • Cronos Testnet
      • Devnet
      • Best Practices
      • Cronosd build with Nix
      • VersionDB
      • MemIAVL
      • Local State Sync
    • Cronosd
  • CRONOS PLAY
    • Introduction
    • Unity Engine
      • Current Version
      • Legacy Version
        • EVM
        • Login Example
        • Custom RPC
        • ERC20
        • ERC721
        • ERC1155
      • Useful Links
    • Unreal Engine
      • Installation and Enabling
      • Working with Blueprint
        • Actors and Blueprint Classes
        • Cronos Configuration
        • Connect Defi Desktop/Onchain Wallet with URI
        • Connect Wallets with QR Code
        • Connect WalletConnect Step by Step
        • WalletConnect 2.0 and Unreal Engine 5: Hello World Example
        • Wallet
        • ERC20
        • ERC721
        • ERC1155
        • Broadcast Transactions
        • Get Tokens or Transactions
      • Working with C++
        • Creating a C++ Project
        • Creating a child DefiWalletCoreActor
        • Querying a contract
        • Customizing Network
      • Demo
    • Cronos Play C++ SDK
    • Crypto.com Pay Integration
    • Cronos Play FAQ
  • Block Explorers
    • Block Explorer and API Keys
    • Cronos Explorer
    • Cronoscan
  • CRONOS CHAIN PROTOCOL
    • Chain ID and Address Format
    • Cronos General FAQ
    • Genesis
    • Modules
      • module_bank
      • module_distribution
      • module_slashing
      • module_feemarket
    • Chain Details
      • List of parameters
      • Technical glossary
      • Protocol Documentation
    • Common IBC Commands
  • Cronos zkEVM
    • Cronos zkEVM
  • Resources
    • Media / brand kit
Powered by GitBook
On this page
  • Cronos EVM: how to verify smart contracts on multiple blockchain explorers
  • Step 1: Obtain smart contract data from a blockchain explorer (e.g., Cronoscan)
  • Step 2: Reformat the SourceCode fields' value
  • Scenario 1: Standard JSON input (starts with "{{" and ends with "}}").
  • Scenario 2: Source code only, with a single source file (starts with actual source code).
  • Scenario 3: Source code only, with multiple source files (starts with a single “{“ and ends with a single "}").
  • Step 3: Submit contract verification into the other blockchain explorer (e.g., Cronos Explorer)
  • Troubleshooting

Was this helpful?

Edit on GitHub
  1. FOR DAPP DEVELOPERS
  2. Smart Contracts

Contract Verification Export: Cronoscan To Cronos Explorer

PreviousContract Deployment and VerificationNextBest Practices

Last updated 3 months ago

Was this helpful?

Cronos EVM: how to verify smart contracts on multiple blockchain explorers

As a developer, you may have submitted your smart contract code to a blockchain explorer (e.g., ) as part of your smart contract deployment script. You can also submit it to other platforms for verification (e.g., ).

This guide explains how to export data from one explorer and upload it into another. However, this only works for one smart contract at a time.

Step 1: Obtain smart contract data from a blockchain explorer (e.g., Cronoscan)

Cronoscan provides an for registered users to retrieve contract source code and compilation settings:

https://api.cronoscan.com/api?module=contract&action=getsourcecode&address={YourContractAddress}&apikey={YourApiKeyToken}

The parameters are as follows:

  • YourContractAddress: address of your smart contract on Cronos EVM chain.

  • YourApiKeyToken: API key on the Cronoscan platform.

The output may look like this (example from this contract: )

The endpoint's response includes the following fields:

  • ContractName: Name of contract

  • CompilerVersion: Version name of compiler for contact

  • ConstructorArguments: Argument inputs used when creating the contract

  • OptimizationUsed: the value is "1" if optimization was used when compiling this contract

  • Runs: Number of times the optimization was run

  • SourceCode: The source code field's value must be reformatted first. See the instructions below.

Step 2: Reformat the SourceCode fields' value

The source code field's value may be provided in one of the three following formats:

Scenario 1: Standard JSON input (starts with "{{" and ends with "}}").

In this case, you need to create a .JSON file by following these steps:

  • Remove the outer brackets "{" and "}"

Scenario 2: Source code only, with a single source file (starts with actual source code).

In this case, you need to create a .SOL file. Copy the code and paste it into a new solidity file that you can name, for example, source_code.sol.

Scenario 3: Source code only, with multiple source files (starts with a single “{“ and ends with a single "}").

In this case, you need to create a .JSON file by following these steps:

  • Create a new JSON file that you can name, for example, source_code.json, using the template below:

{
    "language": "Solidity",
    "sources":**Paste here**   ,
    "settings": {
        "optimizer": {
            "enabled": true,
            "runs": 200
        }
    }
}
  • In the JSON file that you just created, update the "enabled" and "runs" values to match the OptimizationUsed (where 1 should be converted to true) and Runs values from the Cronoscan response.

  • Paste the unescaped JSON string into the JSON file, where "**Paste here**" is a placeholder for where you should insert the unescaped JSON string obtained in the previous step.

{
    "language": "Solidity",
    "sources": {
        "XXX.sol": {
            "content": "Source code of XXX..."
        },
        "YYY.sol": {
            "content": "Source code of YYY..."
        }
    },
    "settings": {
        "optimizer": {
            "enabled": true,
            "runs": 200
        }
    }
}

Step 3: Submit contract verification into the other blockchain explorer (e.g., Cronos Explorer)

You can use the elements from Step 1 to complete the corresponding inputs:

  • Contract Name: Refer to the ContractName field from the Cronoscan response.

  • Contract Address: Address of the contract.

  • Compiler Type: there are two possible scenarios, depending on the format of the source code file generated in Step 2.

    • Scenario 1: The source code is a Solidity file (such as source_code.sol), generated from a SourceCode value in Source code-only format with a single source file. In that case:

      • Compiler Type: select Solidity Files.

      • Contract Files: Upload the solidity file (.sol) generated in Step 2.

      • Optimizer Enabled: Toggle yes if the OptimizationUsed field from the Cronoscan response is 1.

      • Optimizer Runs: If Optimizer Enabled is toggled, use the value from the Runs field in the Cronoscan response.

    • Scenario 2: The source code is a JSON file (such as source_code.json) generated from a SourceCode value either in Standard JSON input format or in Source code-only format with multiple source files. In that case:

      • Compiler Type: select Solidity Standard-Json-Input.

      • Check and, if necessary, edit the value of the JSON file as follows:

        • Double check the value of the settings.optimizer.enabled field. It must be set to true if the OptimizationUsed field from the Cronoscan response is 1. If there is a mismatch, fix it manually in the source_code.json file.

        • Double check the value of the settings.optimizer.runsfield. It must be set to match the value of the Runs field from the Cronoscan response. If there is a mismatch, fix it manually in the source_code.json file.

  • Contract Files: Upload the JSON file (.json) generated in Step 2.

  • Compiler Version: Use the value of the CompilerVersion field from the Cronoscan response.

  • Constructor Arguments: Use the ConstructorArguments field from the Cronoscan response.

An example of the completed form is shown below:

After submitting the form, you are done!

Troubleshooting

  • Specify the address of the smart contract.

  • Attach the JSON or SOL file generated in Step 2.

  • Attach a screenshot of the verification form you completed.

Most of the time, the errors are caused by mistakes when generating the JSON or SOL source code file.

"Unescape" the JSON string. This means replacing the backslashed characters with non-backslashed characters. You can use various tools for this, such as (click: Unescape JSON).

Paste the resulting string into a new JSON file that you can name, for example, source_code.json. The JSON file should now be in .

"Unescape" the JSON string (Once only). This means replacing the backslashed characters with non-backslashed characters. You can use various tools for this, such as (click: Unescape JSON).

Please visit the , which looks like this:

If you encounter errors, please email , making sure that you:

📃
freeformatter
this format
freeformatter
Cronos Explorer User Interface
contact@cronoslabs.org
Cronoscan
Cronos Explorer
endpoint
https://cronoscan.com/address/0x7de56bd8b37827c51835e162c867848fe2403a48#code