How to Develop your first Ethereum Smart Contract with Remix IDE

Posted By : Pradeep

May 20, 2022

Create and Deploy our First Smart Contract to the Ethereum Blockchain
 

We will be using the web version of Remix IDE,  to write and deploy our smart contract.

 

Definition:- "A smart contract is a program that runs on the Ethereum blockchain. It is a set of code (which determines its functions) and data (which determines its state) that is stored at a particular address on the Ethereum Blockchain."

 

Getting Familiar With Remix:-

 

"Remix IDE is an open-source web and desktop application. It encourages a quick development cycle and includes a wide variety of plugins with simple user interfaces. Remix is used for the entire journey of contract development as well as act as a playground for learning and teaching Ethereum."

 

 

This looks like any other IDE. In the sidebar, you have 3 tabs, for now:

 

1- The file explorer, as seen in the picture above.

 

2- The solidity compiler. ** This is where we will compile our smart contract, once it is ready.

 

3- Deploy and run transactions, which is, you guessed it, where we will send our smart contract to the Blockchain.

 

Writing a Basic Smart Contract 


We will write a smart contract that will enable people to store and retrieve information on the blockchain.

 

The first function will allow a user to store information on the blockchain.

 

The second function will allow users to retrieve that stored information on the blockchain.

 

Let's get started! 

 

Create a new file in the contracts folder and name it newContract.sol. 

 

Then incorporate the following lines from our contract:: 

//SPDX-License-Identifier: MIT

pragma solidity 0.8.12;

contract newContract{

uint a=5;

uint b=6;

function add() external returns( uint ){

return a+b;

}

}

 

Explanation:

 

The first line is the license declaration.

 

The compiler version to be used for the current solidity file is specified in the second line's directive.

 

The third line is the contract declaration.

 

The contract has two variables a,b and an external function add which will return the sum of a and b.

 

Compile:- 

 

To compile, you have to select the right contract and then click on the deploy button on the left side of remix ide.

 

Deploy:- 

 

To deploy this contract select the `injected Web3` as your environment. This will connect to the network that your wallet is connected to. 

 

Clicking on deploy will open a meta mask which will ask you to confirm the transaction. After confirming the transaction, the contract will be deployed to the network.

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

November 21, 2024 at 11:06 am

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button

Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text