Solidity is the programming language used for Ethereum smart contracts on the Ethereum Virtual Machine (EVM). In this tutorial, we will use Remix, an IDE (Integrated Development Environment) recommended by Ethereum to write and test Solidity contracts. In just three lines of code, we will create our first Solidity program called "HelloWeb3."
Before you begin, make sure you have the following:
Go to remix.ethereum.org to open the Remix IDE in your web browser. Once the IDE loads, you will see three buttons on the left menu: File, Compile, and Deploy. We will use these buttons to create and deploy our Solidity contract.
Click on the "Create New File" button and name the file "HelloWeb3.sol". In the new file, copy and paste the following three lines of code:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract HelloWorld {
string public message;
constructor() {
message = "Hello, Web3!";
}
}
Let me explain what each line of the code does:
Now, when you deploy this contract and access the "message" variable, you will see the string "Hello, Web3!" displayed.