Hello World in Solidity

Hello World in Solidity Featured Image

Hello, everyone! I’d like to welcome you to the newest community blog entry of the Hello World in Every Language series. Today’s post will cover Hello World in Solidity, a contract-oriented programming language used to write and implement smart contracts invented in 2014.

Table of Contents

Solidity Background

To understand Solidity, it is imperative to comprehend the context in which it is used. So, the first question to ask is: what is a smart contract?

Smart Contract

According to WikipediaOpens in a new tab., a smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. They allow the performance of credible transactions without third-parties.

The contracts used in this sense are the exact same as the regular contracts you’re familiar with. By removing the human factor and voiding the need for a third-party, people and business are able to save money and reduce the chance of fraud. Smart contracts are the main driving force of blockchains.


According to WikipediaOpens in a new tab., a blockchain is a continuously growing list of records, called blocks, which are linked and secured using cryptography. Each block typically contains a cryptographic hash of the previous block, a timestamp, and transaction data.

Blockchain is the force driving the technology of all digital currencies. A couple of examples are Bitcoin, Ripple, Ethereum, Litecoin, Nem just to cite a few.

BlockgeeksOpens in a new tab. has a great analogy which should help you understand blockchain works:

Picture a spreadsheet that is duplicated thousands of times across a network of computers. Then imagine that this network is designed to regularly update this spreadsheet and you have a basic understanding of the blockchain.

Another wonderful description provided by William MougayarOpens in a new tab. goes as follows:

Imagine two entities (eg banks) that need to update their own user account balances when there is a request to transfer money from one customer to another. They need to spend a tremendous (and costly) amount of time and effort for coordination, synchronization, messaging and checking to ensure that each transaction happens exactly as it should.

Typically, the money being transferred is held by the originator until it can be confirmed that it was received by the recipient. With the blockchain, a single ledger of transaction entries that both parties have access to can simplify the coordination and validation efforts because there is always a single version of records, not two disparate databases.

Hello World in Solidity

Without further ado, here’s an implementation of Hello World in Solidity:

pragma solidity ^0.4.22; 
contract helloWorld {   
    function renderHelloWorld () public pure returns (string) {       
        return 'Hello, World!';             

While the format of Solidity looks a bit different from the more popular programming languages today, what’s happening behind is fairly straightforward.

First we import the version of Solidity we’d like to use. Then we create a function and specify we’d only like to return a string. And, voila!

How to Run the Solution

If you want to run the solution, remix provides an IDEOpens in a new tab. you can visit to write and execute the smart contract. Every piece of code written in Solidity—or any blockchain programming language—is considered a smart contract.

Sample Programs of Every Language

Thanks again for stopping by! If you hadn’t noticed, this article was contributed by a community member, Maximillian Naza. If you’d like to help contribute to this series, consider reaching out. We’re always looking for new authors.

Oh, and if you really enjoyed this article, don’t forget to give it a share. By spreading the word, you’ll help grow a fun collection of code snippets.

Until next time!

Recent Posts