“Hello World” Smart Contract in Remix-IDE

What do you mean by Smart Contract?

Smart contracts are self-executing contracts. The term was coined by Nick in 1994. Smart contracts are very different from traditional software programs. They are immutable once deployed on the blockchain. It was because of Ethereum the term smart contract became so popular and used in the Ethereum blockchain.
Solidity is the main programming language for writing smart contracts for the Ethereum blockchain. It is a contract-oriented language, which means that smart contracts are responsible for storing all of the programming logic that transacts with the blockchain. The term smart in smart contracts is as the contract gets executed depending upon some logical condition and all nodes in blockchain have the same copy of that smart contract.

What is Remix-IDE?
The Remix is an Integrated Development Environment(IDE) for developing smart contracts in Solidity programming language. The IDE can be used to write, compile, and debug the Solidity code. It was written in JavaScript and supports testing, debugging and deploying smart contracts, and much more.
Remix-IDE can be accessed in many different ways:

  1. You can use it online in any browser of your choice, by entering the URL: https://remix.ethereum.org/ in the browser.
  2. Or you can install it in your own system using this link.
  3. The third way is to use Mist (the Ethereum Dapp browser).

Getting Started

This article is all about writing your first smart contract in solidity using remix-ide which is a browser-based IDE. So let’s get started with our first simple “Hello World” program.

  1. Open the remix-ide in your browser by typing: https://remix.ethereum.org/
  2. You will be presented with following screen:
  3. Click on the “file explorer” icon onto the left side bar (indicated by blue arrow in the above picture).
  4. Select Solidity in the Environment and click + symbol right to the browser.
  5. Type the file name “HelloWorld.sol” and enter the following code into it

    // My First Smart Contract 
    pragma solidity >=0.5.0 <0.7.0;
    contract HelloWorld {
        function get()public pure returns (string memory){
            return 'Hello Contracts';
        }
    }
    

  6. Once done click the icon just below the “file explorer” icon as shown below:
  7. You will be presented with following screen:
  8. Click “Compile HelloWorld.sol”. Leave rest setting as it is.
  9. Once compiled successfully click the icon below “Solidity Compiler” that is “Deploy and run transactions”. You will be welcomed by next screen:
  10. Without changing any of the values as shown above just click “Deploy” button to deploy your smart contract. Once deployed you will find your smart contract just below in “Deployed Contracts” heading:
  11. Click “>” before your contract you will see a button “get” below as our contract has get function that returns a string. Click get button and you will get :
  12. Congratulations !!! on running your first smart contract in solidity

    References:

    1. https://en.wikipedia.org/wiki/Smart_contract
    My Personal Notes arrow_drop_up

    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.