DEV Community

Cover image for Running Your First Smart Contract with Solidity using Remix IDE. (For Newbies)
Sunington
Sunington

Posted on

Running Your First Smart Contract with Solidity using Remix IDE. (For Newbies)

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.

Remix IDE Homepage

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

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

STEP FOUR

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

Remix Compile

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

STEP SIX

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

Remix Deployed image

STEP SEVEN

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

Output = 3

Image description

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.

Until we meet again,

#KeepSunning.

Discussion (0)