Home DevelopmentSolidity “Hello World” in Solidity

“Hello World” in Solidity

by Godspower Eze
Published: Last Updated on

The “Hello World” program is most likely the first thing you would learn when trying to learn a new language.

Here’s what a “Hello World” smart contract in Solidity looks like:

What is Solidity?

Solidity is statically typed, object-oriented, and high-level language for building smart contracts.

Code Walkthrough

    • Solidity files take the extension .sol
    • // SPDX-License-Identifier: MIT – specifies the license used by this contract. It’s not mandatory but it’s important since smart contracts are open source.
    • pragma solidity 0.8.0; – specifies the version of solidity that should be used during the compilation of the contract. It’s required for the code to run.Other variations like pragma solidity ^0.8.0;, pragma solidity >=0.8.0;, pragma solidity <=0.8.0; and pragma solidity >=0.4.22 <0.8.0; can also be used to specify versions greater or equal to 0.8.0, versions greater or equal to version(same as the previous), versions less than or equal to 0.8.0 and versions greater than or equal to 0.4.22 but less than 0.8.0 respectively.
    • contract HelloWorld {...} – creates a code block for writing the logic of the smart contract. This is similar to defining classes in object-oriented programming languages.
    • string public greeting = "Hello World";  – as a statically-typed language the data type needs to be specified. Here, a string is used.The public keyword is a visibility modifier. And, the greeting is the variable name.public makes it possible for the variable greeting to be called a getter function greeting()


Congratulations!! you just wrote your first smart contract in solidity. Go ahead and try the code on Remix.

Just as this is your first, this is also our first post on here. First of many.

Good luck on your journey.

Related Posts


Anthony Nwike March 21, 2022 - 1:04 pm

Very Insightful – Thanks for sharing.

Tomiwa March 23, 2022 - 11:09 am

Thank you Godpower. This was insightful

Understanding Smart Contracts - Blockchain to the World April 13, 2022 - 8:14 am

[…] in 2015 allowing developers to build smart contracts with a turing-complete programming called Solidity. Since then other smart contract compatible blockchains and more languages for building them have […]


Leave a Comment