Deploying and Verifying Smart Contracts on the Conflux eSpace Testnet Using Remix

Deploying and Verifying Smart Contracts on the Conflux eSpace Testnet Using Remix

In this post, I’ll guide you through the process of deploying and verifying a smart contract on the Conflux eSpace Testnet using the Remix IDE. Whether you’re a beginner or an experienced developer, this step-by-step tutorial will help you understand how to work with smart contracts on the Conflux blockchain. Let’s get started!

For live examples and additional resources, check out the following:

Overview of the Smart Contract

In this tutorial, we’ll work with a simple smart contract that allows users to set and retrieve a value. This straightforward example will serve as an excellent introduction to deploying and verifying contracts on the Conflux eSpace Testnet.

Step 1: Compile the Smart Contract

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

contract SimpleStorage {
    uint256 public storedData;

    // Function to set the value
    function set(uint256 _value) public {
        storedData = _value;
    }

    // Function to get the value
    function get() public view returns (uint256) {
        return storedData;
    }
}

First, we need to compile the smart contract in Remix. Open the Remix IDE and paste your contract code into a new file. Once you have your code ready, click the “Compile” button. If everything is correct, you should see a message indicating that the compilation was successful.

Step 2: Connect to MetaMask

Next, we’ll connect our MetaMask wallet to the Conflux eSpace Testnet. Ensure that you have the MetaMask extension installed in your browser and that your wallet is set to the eSpace Testnet network. Once connected, we’re ready to deploy the smart contract.

Step 3: Deploy the Smart Contract

Now that we’re connected, let’s deploy the contract. Click on the “Deploy” button in Remix. After a successful deployment, you’ll see the contract address displayed in the console.

To verify the deployment, you can paste this address into the Conflux block explorer. Initially, the contract will not be verified, but we will take care of that in the next step.

Here’s the smart Contract Address: 0x4255a2aDE53909ABd78a97ee9bEdE6AFDe09E0F8

Step 4: Verify the Smart Contract

To verify your contract, you’ll need to fill in several fields: the contract name, license, compiler version, and the flattened code. Before you proceed, ensure that you have installed the “Flatten” plugin in Remix. This plugin is essential because it allows you to combine all contract dependencies into a single file, which is necessary for the verification process.

  1. Flatten the Code: Use the Flatten plugin to combine your contract code. This step is crucial, as verification requires a complete code view.

  2. Copy the Flattened Code: Once flattened, copy the entire code.

  3. Fill in the Verification Form: On the contract verification page, paste the flattened code. You will also need to provide the contract name, select the MIT license, and specify the compiler version (0.8.20 in our case).

  4. Submit the Verification: After filling in all the required information, submit the form.

Once the verification process is complete, you should see a green checkmark next to your contract. Additionally, you’ll gain access to various functionalities such as “Read Contract,” “Write Contract,” and the complete smart contract code, including the ABI.

Here’s the Txn: https://evmtestnet.confluxscan.net/address/0x4255a2ade53909abd78a97ee9bede6afde09e0f8?tab=contract-viewer

Conclusion

And there you have it! You’ve successfully deployed and verified a smart contract on the Conflux eSpace Testnet using Remix. I hope this tutorial has clarified the process for you. If you have any questions or need further assistance, feel free to reach out in the comments below.

Thank you for reading, and happy coding!

1 Like