Running Your First Smart Contract with Solidity using Remix IDE. (For Newbies)
Tags: blockchain, web3, smartcontract
Published: 2022-06-12 06:33:35

Since you are here, I promise you one thing : You will learn how to run your first smart contract coded in solidity.

Wait solidity? what is that?

**Solidity is a contract-oriented, statically typed high-level programming language for implementing smart contracts.**

**Solidity** is used to write contracts in DApps, DeFi, NFTs Applications and even to building Web3 Application from scratch.

It is highly influenced by C++, Python and JavaScript and has been designed to target the Ethereum Virtual Machine (EVM).

To write our first Smart Contract, we will be using Remix IDE to Compile and Run our Solidity Code base.

Let's begin...


**STEP ONE**


Head over to https://remix.ethereum.org to start your remix coding environment (Online Editor)

**Or**

You can get the offline (For Desktop) [here](https://github.com/ethereum/remix-desktop/releases).

![Remix IDE Homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa3lvgjxd7wn0sp39cxq.PNG)


**STEP TWO**


Next is to create a Solidity file. To do that head over to ‘File Explorer’ then click on ‘Create File’ following the marked area on the picture below.

Note : You can name it whatever you want but make sure to end it with ‘.sol’


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njpl8n0kcgok1qfjc6gy.PNG)
  

**STEP THREE**

Copy the code below and paste in Remix IDE coding section.


Code Example


`pragma solidity ^0.5.0;
contract SolidityTest {
   constructor() public{
   }
   function getResult() public view returns(uint){
      uint a = 1;
      uint b = 2;
      uint result = a + b;
      return result;
   }
}`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0suf42znszkr30d9w97.PNG)


**STEP FOUR**

Under Compile Tab, click Start to Compile button to compile your Solidity code.


![Remix Compile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7sa73wh7poo0uhqwv8n.PNG)
 


**STEP FIVE** 

Next is to deploy and run your code. To do that go to the ‘Deploy and Run Transactions’ tab, then click ‘Deploy’ button. Make sure all the parameters under the run and deploy section is set right from img below.


![Remix Deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6esxud9t227ox9egdpb.PNG)
 


**STEP SIX**

Under Run Tab, where you will see the Transaction record,, Select 0x75a05ff94d0c9608b8265bc08… in drop-down.


![Remix Deployed image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4c7n6sixcx16k8hj67v.PNG)
 

**STEP SEVEN**

To get the deployed result, Click ‘getResult’ button to display the result in the terminal.

Output = 3

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdntfd497ddk6jvkxwej.PNG)
 


**VIOLA!** You just deployed your first Smart contract!



**To explain what we just did.**

We assigned value a = 1, (`uint a = 1`) and b = 2  (`uint a = 1`) . Then we carried a simple math operation in solidity.

`uint result a + b` = (1 + 2) = 3. 

Therefore `3` is the right output.

This is just the surface of writing smart contracts in solidity. As you go on, you get to see more complex code.

I’m Sunington, you can connect with me on [Twitter](https://twitter.com/sunington).

Until we meet again,

_#KeepSunning._