Deploying the Smart Contract

We'll be using Remix to deploy our smart contract. Remix is an online code editor that allows you to easily edit and deploy smart contracts.

Here's the source code for the smart contract we'll be using for this tutorial. It already comes included with Remix and can be found under the contracts folder.

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 * @custom:dev-run-script ./scripts/deploy_with_ethers.ts
 */
contract Storage {

    uint256 number;

    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    /**
     * @dev Return value 
     * @return value of 'number'
     */
    function retrieve() public view returns (uint256){
        return number;
    }
}

After compiling the contract in the compiler section, go to the deployment section and select Injected Provider as the environment, make sure that the right contract file is selected.

Finally, connect your metamask and hit deploy. For this tutorial we'll be deploying to the Rinkeby test network, but you can deploy to any EVM compatible network you want. You can get free Rinkeby Eth here.

Last updated