Getting started with Remix - Ethereum IDE
Tags: web3, programming, blockchain, solidity
Published: 2021-12-19 04:43:49

Remix IDE is an open-source web and desktop application. It is a powerful open-source tool that helps you write Solidity contracts straight from the browser.

Remix-IDE is available at [remix.ethereum.org](https://remix.ethereum.org/). The project is available at [GitHub Repository](https://github.com/ethereum/remix-project) and the docs are available at this [link](https://remix-ide.readthedocs.io/en/latest/).

When you first visit remix you will see this window


![An Image of remix homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4iyb700snz9qdrncmbo.png)

There will be three default folders in remix namely `contracts`, `scripts`, and `tests`. 

There will be three smart contracts( .sol files ) inside the contracts folder and two scripts( .js files ) inside the scripts folder and one test( .sol file ) inside the test folder


## Creating a new Smart Contract in Remix

Create a new `MyContract.sol` file inside the contracts folder. You can create a new file by clicking the file button at the top of the folders.

<center>
![An Image of file icons on top of folders](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9k9ofg50rc0ghkavwaf.png)
</center>


## Creating Smart Contract logic

We will create a simple smart contract that will store and update a variable in the blockchain.

```
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract MyContract { 
    // state variable num
    uint256 public num;
    
    // function sets value of variable num equal to _num 
    function setNum(uint256 _num) public returns(uint256) {
        num = _num;
        return num;
    }
}
```
You can view the gist at [MyContract.sol](https://gist.github.com/AbhinavXT/7a9ea55b2eac95acbd265e134d3d216a).

For learning more about solidity visit [Solidity by Example](https://solidity-by-example.org/)

## Compiling and Deploying the contract

To compile the contract click on the solidity icon on the left menu. 

<center>
![An Image of solidity compiler on remix](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/edadlwksu7uc52n1vnvi.png)
</center>

Now click on `Compile MyContract.sol` to compile the contract. If the contract compiles perfectly, you will see a green tick with the solidity icon(as shown in the image above).

To deploy the contract click on the ethereum icon on the left menu and then click on the `Deploy` button.

<center>
![An Image of deploy and run transaction on remix](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqjqd741bv1hxkiiwzh5.png)
</center>

After deploying the contract you will see your contract under the deployed contracts(as shown in the image above).

Now we can test the smart contract by updating the `num` variable.

## Updating the variable

We can update the `num` variable, using the `setNum` function by entering an integer value as shown below and then clicking on `setNum`(in orange color). This will store the integer value, that we enter inside the num variable.

<center>
![An image showing functions and updated variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6je6th5mqywdedlft5u1.png)
</center>

Now you can check the value of the variable by clicking on `num`(in blue color). The value stored inside num will be displayed below it(as shown in the image above).


**Congratulations!You have built and tested a smart contract on Remix.**

Hope you enjoyed the article! If you have any questions or comments, feel free to drop them below or reach out to me on [Twitter!](https://twitter.com/AbhinavXT)