Deploying contracts with Remix

Prerequisites:

  • MetaMask: Ensure you have MetaMask installed in your browser and have a Creditcoin EVM account set up with some CTC for gas fees.

  • Remix: Access the Remix IDE

Before starting

  • Ensure your MetaMask account is unlocked and has sufficient CTC to cover gas fees for the deployment.

  • Always review the gas fees and transaction details before confirming transactions in MetaMask.

  • Make sure you're deploying the correct contract and verify its functionalities before using it in a production environment.

Step 1: Write or Import Your Smart Contract

  1. Open Remix in your browser.

  2. Create a new file or import an existing smart contract code (Solidity). You may use the following Counter.sol contract:

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

contract TestCounter {
    int private count = 0;
    function incrementCounter() public {
        count += 1;
    }
    function decrementCounter() public {
        count -= 1;
    }

    function getCount() public view returns (int) {
        return count;
    }
}

Step 2: Selecting the Compiler

  1. In Remix, navigate to the "Solidity Compiler" tab on the left-hand side.

  1. Ensure the correct version of the Solidity compiler is selected for your smart contract by checking the compiler version is equal to or newer than the version stated in the pragma line.

  2. Compile your smart contract code by clicking on the "Compile" button.

Step 3: Deploying the Smart Contract

  1. Go to the "Deploy & Run Transactions" tab in Remix.

  1. From the Environment dropdown, select "Injected Web3" to connect Remix to MetaMask.

Step 4: Connect MetaMask

  1. MetaMask will prompt you to connect your account when you select "Injected Web3." Click "Connect" to establish the connection.

  2. Confirm the connection by selecting the Ethereum account you want to use for deploying the smart contract.

Step 5: Deploy Your Smart Contract

  1. Under the "Deploy & Run Transactions" tab, you'll see your compiled contract displayed.

  2. Find the contract you want to deploy and click on the blue "Deploy" button.

  3. MetaMask will open and prompt you to confirm the transaction. Review the gas fees and click "Confirm" to deploy the contract.

  4. Wait for the transaction to be confirmed on the Ethereum network. Once confirmed, your contract will be deployed, and Remix will display the contract's address.

Step 6: Interact with Your Deployed Contract

  1. Remix will provide you with the deployed contract's address. You can use this address to interact with your smart contract.

  2. Utilize Remix's interface to interact with the contract, executing its functions, and observing state changes.

Last updated