DEV Community

Cover image for Getting started with Remix - Ethereum IDE
Abhinav Pathak
Abhinav Pathak

Posted on • Updated on

Getting started with Remix - Ethereum IDE

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. The project is available at GitHub Repository and the docs are available at this link.

When you first visit remix you will see this window

An Image of remix homepage

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.

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

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;
    }
}
Enter fullscreen mode Exit fullscreen mode

You can view the gist at MyContract.sol.

For learning more about solidity visit Solidity by Example

Compiling and Deploying the contract

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

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

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.

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

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.

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

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!

Top comments (1)

Collapse
 
mariabulter profile image
MariaBulter

How do you use remix Solidity IDE? spell to make him stop cheating