In this walkthrough guide, I will be taking you by hand to examine the “Hello World” Solana program codebase written in Solidity with Solang.
1.1 Why Walkthrough Codes As A Developer😜
One of the best ways to solidify your understanding of any programming language and development process is to go through real-life example codes to see how things are actually implemented for real.
That’s why, I will be going through the official Solana Labs program examples repo in the series to help you get a better understanding of your journey to becoming a Solidity developer on Solana.
1.3 Get Stuck? Get Support✋
I understand based on experience with developers that things can always break or get difficult to figure out, especially for beginners.
That is why you can join Discord below to get support if get stuck.
Join dProgrammingUniversity Discord Server – I have created a dedicated channel #Solana (under the BLOCKCHAINS category) to give support to my Solana developer content like this guide. So, feel free to ask questions in there if stuck with this guide.
Follow me on Twitter
We may hold, invest, trade or receive rewards/grants/bounty/tokens from reviewed/discussed web3 projects/affiliates (before, during or after this content was published).
All our contents at dProgramming University are for educational purposes only and do not constitute financial, trading, investment or development advice.
Please do your own research (DYOR).
By using or following the whole or part of this content, you agree that we are not liable for any losses that you may suffer thereafter.
2.0 Pre-Requisite For This Code Walkthrough Guide🤔
Let’s get into the codes right away. But, before that, there are a few things to check to ensure you can follow this guide.
1. Solidity programming language:
At least basic knowledge. If you are new to Solidity, check out my free beginner course to building your first smart contract with Solidity below:
At least basic knowledge of Solang and how it makes it possible to build and deploy Solana programs in Solidity even though Solana is not an EVM-compatible Blockchain. If you are new to Solang, then the best place to start is with my beginner-friendly guide (article and videos):
3. Setup Solana development environment for Solang Solidity:
Not to worry, I got you covered with my beginner-friendly step-by-step video on Solana development environment setup for Solidity developers transitioning to Solana below:
Once, you have the above pre-requisite fixed, then you are good to go with me for the live Solang Solidity Solana program code.
3.0 VIDEO: Hello World Solang Solidity Solana Program Example Codes Walkthrough🚶
I have a step-by-step- video for this Solang Solidity smart contract walkthrough.
Watch me go through the Hello Solana program code walkthrough in the video below:
4.0 TEXT: Hello World Solang Solidity Solana Program Example Codes Walkthrough🚶
I will break it into simplified steps to follow. Let us go:
STEP 1: Open Solana Program Examples Repo
The first step is to locate the Solana program examples repo on Solana Labs’s official GitHub account.
STEP 2: Clone the Repo and Open it in a Code Editor
The next step is to clone the full Solana Example repo on your computer (am using Linux Ubuntu) but this works fine too for MacOS and Windows (via WSL).
After cloning, run the command in the same terminal:
And then if using VS code as your code editor, run:
This will open the cloned “program-examples” folder in VS code.
STEP 3: Select the “basics” folder
In the code editor, open the “basics” folder
STEP 4: Select “hello-solana” example program folder
Open the “hello-solana” example program folder. That is the precise Solana program example I will be walking you through the code in this series, and in future posts, will touch on others too.
STEP 5: Select the “solang” folder
Considering the focus is on Solidity smart contract and not Rust, Python and others. Kindly click the “solang” folder to unveil the actual Solidity smart contract code we will be working with.
STEP 6: Explore the files and folder and what they do
The most important files and folder in the “solang” folder is the “.sol“, “test” and “Anchor.toml“.
Want to learn more, watch the walkthrough video of this article above.
STEP 7: Select the “solidity” folder
To access the actual Solang Solidity smart contract code, you need to open the “solidity” folder to access the “hello-solana.sol” file.
STEP 8: Select the “tests” folder
To test if the Solidity smart contract is working after deployment as a Solana program, the test file is needed to execute the test script.
STEP 9: Select the “Anchor.toml”
The “Anchor.toml” is an essential Anchor framework config file to handle the building, deployment and testing of the “hello-solana” Solidity Solana program.
STEP 10: Install dependencies
It is essential to ensure installing all needed dependencies by running the command:
STEP 11: Build, Deploy and Test the Solang Solidity Solana Program
To build, deploy and test the “hello-solana” program, run the Anchor test command:
STEP 12: To see the log message after a successful deployment
The last thing to do is check for the log to see the Solana program message send via the Solidity smart contract.
To see that, open the auto-generated “.anchor” folder to check the log file inside “program-logs” based on the program id.
Congratulations, we just completed a Solang Solidity Solana “Hello World” program walkthrough.
We built, deploy and tested it successfully.
Do the following exercise to solidify your learning:
- Follow the walkthrough video above
- Change the Solidity constructor function log greeting from “Hello, Solana!” to “Hello, dProgramming University From Your_name_here” (the name must be your discord username ou will use to submit the exercise)
- Build & deploy it to Solana local validator.
- Submit the 2 screenshots (1 showing the anchor test executed successfully in your terminal and 2 showing the log message)
- Post the screenshots in the dedicated #Solana channel in the dProgramming University discord server.
All to the dProgramming university discord server in the #Solana channel.
It was an interesting ride and glad you made it to this point.
Congrats👏 once again and it’s time to take positive advantage of the opportunities opened up to Ethereum developers with the integration of Solidity on the Solana blockchain.
6.1 WHAT NEXT?🚀
I aim to create advanced Solidity-based Solana programs and share them in future guides with you. Thus, kindly use the social media share button to share this guide if you have found it helpful or will be helpful to some developers in your social media sphere. And join the discord to stay in the loop.
Thanks for your time, it’s been a wonderful ride with you all this while.
Founder, dProgramming University (dPU).
See you in the next series.