How to deploy your first smart contract on Ethereum

1. Use Remix

First we naviagete to the Remix. And then we can create a new workspace and add a new file from left part interface.

2. Edit the file we added.

I will use the code below as a simple demo.

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.17;

// We define a contract with the name Counter.
contract Counter {

    // Public variable of type unsigned int to keep the number of counts
    // Our contract stores one unsigned integer named count starting at 0.
    uint256 public count = 0;

    // Function that increments our counter
    // The first function will modify the state of the contract and increment() our variable count.
    function increment() public {
        count += 1;
    }

    // The second function is just a getter to be able to read the value of the count variable outside of the smart contract. 
    // Note that, as we defined our count variable as public this is not necessary but is shown as an example.
    // Not necessary getter to get the count value
    function getCount() public view returns (uint256) {
        return count;
    }

}

3. Deploy it!

Deploying the smart contract on the blockchain is actually just sending a transaction containing the code of the compiled smart contract without specifying any recipients.

4. Compile

We’ll first compile the contract by clicking on the compile icon on the left hand side.

5. Run and deploy

Then navigate to the deploy and run transactions screen:

6. Check your smart contract

Once we run our smart contract, then we could find it on bottom:

Leave a Reply