Skip to main content

Command Palette

Search for a command to run...

Writing your First Smart Contract using Remix

Updated
2 min read
Writing your First Smart Contract using Remix
S

Few interesting things about me:

  • Software Engineer @ JP Morgan Chase & Co.
  • AWS Community Builder 2023
  • I love working with technology
  • I enjoy playing video games 😄

What is a Smart Contract?

A smart contract, as defined by Ethereum, is just a program that runs on the Ethereum blockchain.

Much like traditional contracts, they can be used as digital forms of agreement. Executing a smart contract essentially creates a transaction on the blockchain and hence, these transactions are trackable and irreversible.


We can write smart contracts using the Solidity programming language. We'll use the Remix IDE which saves a lot of time in setup because it is online.

You can start working with Remix by following this link.

Open up the Remix IDE for the first time and it looks something like this. You'll have to agree to some stuff and then go through a first-time tour of the options in the sidebar.

The sidebar contains 4 options, the first one is the file structure, which shows you all the different files and folders in your workspace.

You then have a search button, a tab to choose the Solidity compiler (you can change versions here) and a tab where you can deploy your smart contracts.


Writing your first Smart Contract

Create a new file with the name FirstContract.sol. You might've noticed that we use the sol extension, and you guessed it right, it is the extension we use for Solidity files.

I'm on this version of the Solidity compiler. You might have to change your compiler to this one if you want the same results.

Let's write our first contract now.

pragma solidity ^0.8.0;

contract FirstContract {    
    string name = "";

    function setName(string memory _newName) public {
        name = _newName;
    }
}

We can deploy this contract on a JavaScript VM for now.

More from this blog

O

One Byte Social

2 posts

We're a community of tech enthusiasts, developers, and digital creators who love to share their knowledge and connect with each other. Let's grow and learn together, one bit at a time😉