Verify a Smart Contract on the XRPL EVM

After deploying your smart contract on the XRPL EVM, it is essential to verify the contract source code on the XRPL EVM Explorer. Verification ensures transparency and allows users to interact with your contract directly through the explorer.

This guide provides step-by-step instructions for verifying a smart contract using Remix IDE and Hardhat, with a recommended approach for using Standard JSON Input for seamless verification.


Step 1: Access the XRPL EVM Explorer

  1. Open the XRPL EVM Explorer: https://explorer.xrplevm.org.
  2. Locate your deployed contract by searching for its contract address in the search bar.
  3. Navigate to the Contract tab and click Verify & Publish.

Step 2: Select Verification Method

The XRPL EVM Explorer supports multiple verification methods. For detailed and error-free verification, it is highly recommended to use Standard JSON Input generated from Remix or Hardhat.

Why Use Standard JSON Input?

  • Ensures all compiler settings (e.g., optimization, Solidity version) match the deployed contract.
  • Reduces the chance of mismatches between your source code and the deployed bytecode.

Step 3: Verification with Remix IDE

Generate Standard JSON Input in Remix

  1. Open your contract in Remix IDE (Remix).

  2. Compile the contract:

    • Go to the Solidity Compiler plugin.
    • Select the correct compiler version used during deployment.
    • Enable Optimizer if it was used during deployment and configure it to match the deployment settings.
    • Click Compile.
  3. Export the compiler details:

    • Scroll down to Compilation Details and copy COMPILER INPUT.
    • Create a .json file on your local machine and paste the COMPILER INPUT.

Upload JSON Input to XRPL EVM Explorer

  1. Return to the XRPL EVM Explorer's Verify & Publish page.
  2. Select Standard JSON Input as the verification method.
  3. Upload the JSON file you generated from Remix.
  4. Choose the appropriate License Type (e.g., MIT, GPL, etc.).
  5. Click Verify.

The explorer will process the JSON file and verify your contract. Once verified, the contract source code will be published on the explorer.


Step 4: Verification with Hardhat

Generate Standard JSON Input in Hardhat

  1. Open your Hardhat project and navigate to the contract directory.
  2. Compile the contract:
    npx hardhat compile
    
  3. Locate the standard-input.json file in the artifacts directory. This file contains the compiler input and settings.

Upload JSON Input to XRPL EVM Explorer

  1. Go to the Verify & Publish page on the XRPL EVM Explorer.
  2. Select Standard JSON Input as the verification method.
  3. Upload the standard-input.json file generated by Hardhat.
  4. Choose the appropriate License Type.
  5. Click Verify.

The explorer will match the JSON input with the deployed bytecode and verify your contract.


Additional Tips

Matching Compiler Settings

  • Ensure the Solidity compiler version and optimization settings used during deployment match those used for verification.
  • Mismatched settings may result in verification failure.

License Selection

  • Select a license that matches your contract’s codebase. Common licenses include:
    • MIT License
    • GNU General Public License (GPL)
    • Unlicense (No License)

Future-Proofing

  • For upcoming developments involving cross-chain functionality with Cosmos IBC and Axelar GMP, always design smart contracts with interoperability in mind.

Why Verify Your Smart Contract?

  1. Transparency: Verified contracts allow users to view the source code directly on the explorer.
  2. Trust: Builds trust with the community by demonstrating the integrity of the contract.
  3. Ease of Use: Enables users to interact with the contract directly through the explorer’s interface.

By following these steps, you can verify your smart contract seamlessly on the XRPL EVM Explorer. For advanced use cases, you can extend your contract functionality with cross-chain capabilities using Axelar GMP and Cosmos IBC.