๐ŸŸขVerifying with Hardhat or Truffle

How to Verify a Proxy Contract on ARC20 Testnet and Mainnet

When deploying proxy contracts on blockchain networks such as Aveniumโ€™s ARC20 testnet and mainnet, verifying your contract's source code is essential for transparency and security. This guide will walk you through the process of verifying a proxy contract.

Prerequisites

  1. MetaMask: Ensure you have MetaMask installed and connected to the Avenium network.

  2. Remix or Hardhat/Truffle: Have a development environment set up for deploying contracts.

  3. Avenium Testnet/Mainnet Details:

    • Testnet RPC URL: https://connect-testnet.avenium.io

    • Mainnet RPC URL: Coming Soon

Steps to Deploy and Verify a Proxy Contract

1. Deploy the Implementation Contract

Write your implementation contract. For example, a simple implementation might look like this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Implementation {
    uint256 public value;

    function setValue(uint256 _value) public {
        value = _value;
    }
}

Deploy this contract using Remix or your preferred deployment tool.

2. Deploy the Proxy Contract

A basic proxy contract using OpenZeppelinโ€™s TransparentUpgradeableProxy can be deployed as follows:

First, ensure you have the following imports:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

Then deploy the proxy contract:

contract ProxyDeployer {
    TransparentUpgradeableProxy public proxy;

    function deployProxy(address _logic, address admin, bytes memory _data) public {
        proxy = new TransparentUpgradeableProxy(_logic, admin, _data);
    }
}

Here _logic is the address of the deployed implementation contract, admin is the address that can upgrade the proxy, and _data can be used to initialize the proxy.

3. Verify the Implementation Contract

  1. Go to the Avenium block explorer (testnet: testnet.avescan.net).

  2. Navigate to the implementation contract address.

  3. Click on "Verify & Publish".

  4. Enter the Solidity compiler version and optimization settings used during deployment.

  5. Paste the implementation contractโ€™s source code.

  6. Complete the verification process.

4. Verify the Proxy Contract

  1. Navigate to the proxy contract address on the block explorer.

  2. Click on "Verify & Publish".

  3. Select the appropriate proxy contract type (e.g., TransparentUpgradeableProxy).

  4. Enter the Solidity compiler version and optimization settings used during deployment.

  5. Paste the proxy contractโ€™s source code and constructor arguments (encoded as necessary).

  6. Complete the verification process.

Example: Verifying on the Testnet

Assuming you have the proxy and implementation contracts deployed:

  1. Implementation Contract Verification:

    • Compiler Version: Ensure it matches the version you used.

    • Optimization: Should match your compilation settings.

    • Source Code: Directly paste your implementation contract.

  2. Proxy Contract Verification:

    • Contract Address: Use the address where the proxy is deployed.

    • Compiler Version: Ensure it matches the version you used for the proxy deployment.

    • Optimization: Should match your compilation settings.

    • Proxy Source Code:

      • Directly paste your TransparentUpgradeableProxy source code.

      • Constructor Arguments: Include the _logic (implementation contract address), admin, and _data arguments encoded in ABI format if required.

Verifying with Hardhat or Truffle

If you use Hardhat or Truffle, you can also verify your contracts using their respective plugins:

Hardhat

  1. Install the verification plugin:

    npm install --save-dev @nomiclabs/hardhat-etherscan
  2. Configure the plugin in hardhat.config.js:

    require("@nomiclabs/hardhat-etherscan");
    
    module.exports = {
        solidity: "0.8.0",
        networks: {
            testnet: {
                url: "https://connect-testnet.avenium.io",
                accounts: [`0x${process.env.PRIVATE_KEY}`],
            },
        },
        etherscan: {
            apiKey: process.env.AVENIUM_API_KEY,
        },
    };
  3. Verify the contracts:

    npx hardhat verify --network testnet DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1" "Constructor argument 2"

Truffle

  1. Install the verification plugin:

    npm install truffle-plugin-verify
  2. Configure the plugin in truffle-config.js:

    module.exports = {
        // Other configurations...
        plugins: [
            'truffle-plugin-verify'
        ],
        api_keys: {
            etherscan: process.env.AVENIUM_API_KEY
        }
    };
  3. Verify the contracts:

    truffle run verify DEPLOYED_CONTRACT_NAME@DEPLOYED_CONTRACT_ADDRESS --network testnet

By following these steps, you can deploy and verify your proxy contract on the Avenium ARC20 testnet and mainnet, ensuring transparency and trust in your smart contracts. Always double-check your contract addresses and constructor arguments to avoid verification errors.

Last updated