Hello World Smart Contract - Ethereum BlockChain

At the end of this article, you will be able to deploy a Hello World Smart Contract to Ethereum BlockChain. 
  • Basic knowledge of BlockChain and SmartContracts.
  • Basic Knowledge of Ethereum BlockChain. 
Getting Started
Let's get started with building our Hello World Smart Contract. Ethereum uses "Solidity" as a programming language to implement smart contracts. All of the smart contract code written in solidity gets converted to bytecode and EVM (Ethereum Virtual Machines) is responsible for executing all of the bytecodes in the blockchain. 
I will be using remix (Online Solidity Compiler) to run and deploy smart contract codes.  
Hello World Contract
  1. pragma solidity ^0.4.4;  
  3. contract HelloWorldContract  
  4. {  
  5.     function SayHello() returns(string){  
  6.         return "HelloWorld";  
  7.     }  
  8. }  
In the above code, we have created a sample contract called HelloWorldContract and a  function called SayHello which returns HelloWorld. Solidity language is quite similar to javascript syntactically.
Deployment in blockchain refers to deploying the smart contract to all of the nodes that are participating in the network. This is the key difference between centralized and de-centralized application. I will be using remix to deploy. The other most common way to deploy contract is via Truffle or via Metamask.
Go to the "Run" tab and choose Environment as JavaScript VM and click "Create" button. This will deploy our contract to the local node in remix.
We have now deployed our contract to blockchain and now let's invoke the function SayHello. When you click the SayHello button, you must see an output window like below where decoded output prints "Hello World".


Execution cost, gas, and transaction cost is the fee (paid in the ether) for running smart contracts in the blockchain.

  • https://remix.ethereum.org/
  • https://solidity.readthedocs.io/en/develop/

Similar Articles