DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 963,503 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Solidity Hello world
Francesco Ciulla
Francesco Ciulla

Posted on

Solidity Hello world

Hi I am Francesco, and In this short article, I will show you a short step-by-step guide to write your first "Hello World" in Solidity.

Do you prefer the Video Version? just click the link below.

Image description

Remix IDE

Visit http://remix.ethereum.org, and be sure to select "Default Workspace" if it isn't selected already.

Image description

HelloWorld.sol file

In Solidity, the file extension we use is .sol.

Create a new file called "HelloWorld.sol" by clicking the icon ๐Ÿ—’๏ธat the top-left (see the pic below).

Image description

Then Populate the HelloWorld.sol file

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.7;

contract MyContract {
    string public hello = "Hello World";
}
Enter fullscreen mode Exit fullscreen mode

The first line is the license. We write that to avoid compiler warnings.

"pragma solidity" is the version we want to use.

For now, you can think of a "contract" as a class (it's a very similar concept if you are familiar with object-oriented programming).

Personally, I like the fact that Solidity uses reserved keywords such as "contract", and "address", which are very specific to smart contracts and it makes it very clear to understand what's going on.

Compile the "HelloWorld.sol" file

Click on the Solidity logo on the left to access the Compiler.

Image description

Leave everything as default and click the "Compile HelloWorld.Sol" button

Image description

Deploy to test network

One of the reasons why using the Remix IDE is so convenient is that we can deploy automatically on a test network in the browser without the need to set up a whole environment, which is not very simple for someone who is getting started writing Solidity code.

Click the "Ethereum-like" icon on the left, that says "Deploy and run transactions".

Image description

Click the orange "Deploy" button:

Image description

Click the ">" next to "MYCONTRACT AT ..." at the bottom. It's a bit hard to spot if you are not used to that because it's gray. Here is a picture to give you an idea.

Image description

Last step: "Hello World"

Another reason for using Remix is that we can test the value of the variables directly inside the browser!

Click on the "hello" blue button to check the value of the variable we just defined.

Image description

Done!

If you prefer the video version, you can check this 109 seconds video

Image description

I hope this article has been useful. If you want to stay updated you can find me here: http://francescociulla.com

For any questions and doubts, just leave a comment.

Francesco.

Top comments (10)

Collapse
 
sloan profile image
Sloan

This looks like a great article! ๐Ÿ™Œ

In fact, the topic of your post would also work really well in the Meta Punk Community too!

Metapunk Web3 Community ๐Ÿฆ™

Weโ€™re a community where blockchain builders and makers, web3 devs, and nft creators can connect, learn and share ๐Ÿฆ™

favicon metapunk.to

Meta Punk is a really cool international NFT and web3 community where artists, web3 developers, and traders can connect, learn, and share exciting discoveries and ideas. ๐Ÿฆ™

Would you consider posting this article there too? Because Meta Punk is built on the same platform as DEV (Forem) you can fairly easily copy the Markdown and post it there as well.

Really hope that you'll share this awesome post with the community there and consider browsing the other Forem communities out there!

Collapse
 
francescoxx profile image
Francesco Ciulla Author

Thank you so much Sloan

Collapse
 
othimar profile image
Pรฉlรฉ Oussoumanou

It's my first time using those stuff. I don't know what this is used for, but it works ๐Ÿ˜…. Thanks!!

Collapse
 
francescoxx profile image
Francesco Ciulla Author

you are welcome!

Collapse
 
surajondev profile image
Suraj Vishwakarma

Nice post Francesco as always ๐Ÿ”ฅ. I love remix ethereum IDE for writing my smart contractsโšก

Collapse
 
francescoxx profile image
Francesco Ciulla Author

Thank you Suraj! stick with me because there are many more incoming!

Collapse
 
surajondev profile image
Suraj Vishwakarma

Always ๐Ÿ”ฅโšก

Thread Thread
 
francescoxx profile image
Francesco Ciulla Author

lfg๐Ÿš€

Collapse
 
Sloan, the sloth mascot
Comment deleted

๐ŸŒš Life is too short to browse without dark mode