My developer friends keep asking me how to jump into the Web3 world, is it difficult? I often joke that I only need to know a little code and have a free afternoon to write my first smart contract. Really, with Remix IDE, you only need a web browser to write, deploy and interact with smart contracts on the Ethereum blockchain. In this article, I will show you how to do it at once from A-Z, no theory, only practice.
What are these "dishes" that sound so strange?
Smart contract is a piece of code that runs automatically on the blockchain, Solidity is the programming language to write it, and Remix IDE is a browser tool that helps you type the code and test it immediately.
Smart Contract: Automatic "contract", no need for intermediaries
Many people who first hear this word often think it's a big deal. In essence, it is just code containing logical rules that are permanently stored on the Ethereum blockchain [1]. When the conditions are met, the code will automatically execute without the need for anyone to testify or approve the command.
Just imagine it like a vending machine. You insert money, choose water, and the machine automatically releases the water bottle. No need for any cashiers there. This is the core foundation for building decentralized applications (Dapps) in the Web3 world [1]. If you are still confused about this fundamental concept, learning What is Blockchain explained simply for newbies will help you better visualize the overall picture.
Solidity: The "intestinal" programming language to write Smart Contracts on Ethereum
To communicate with the Ethereum virtual machine, we need a specialized language. Learning Solidity to write smart contracts is the most standard step because this is the most popular language and has the strongest support from the community today.
Its syntax is statically typed and is quite similar to JavaScript or C++. Thanks to that, web developers who jump in will find it extremely familiar. By the way, if you don't have a solid programming foundation, a course Learn Basic JavaScript for Beginners 2026 will be the perfect stepping stone before touching Solidity.
Remix IDE: "All-in-one" code browser for Solidity people
Many of you wonder what Remix IDE is and how to use it. Simply put, it is an integrated development environment (IDE) that runs directly in your web browser [1].
You don't need to download heavy software or install a complicated environment on your computer. You don't even need to know how to use Docker for developers practical guide to set up containers running node local in this early stage. Just open a Chrome tab, visit the website and you have enough tools to write, compile and deploy source code.
Dissecting the structure of a basic Smart Contract Solidity
The standard Solidity smart contract structure always starts with the copyright declaration (SPDX), the language version (pragma), then the contract name containing state variables and functions.
First line: What do SPDX-License-Identifier and pragma solidity mean?
Bất kỳ file code nào cũng cần có khai báo đầu tiên để trình biên dịch hiểu. Dòng SPDX-License-Identifier dùng để khai báo giấy phép mã nguồn mở (ví dụ MIT, GPL), giúp tránh các rắc rối về pháp lý và cảnh báo từ compiler sau này.
Tiếp theo là từ khóa pragma solidity. Dòng này chỉ định phiên bản compiler được phép biên dịch code của bạn. Ví dụ pragma solidity ^0.8.24; nghĩa là đoạn code này chạy tốt trên phiên bản 0.8.24 và các bản vá lỗi cao hơn của nó, giúp đảm bảo tính tương thích.
Contract declaration: Like declaring a class in OOP
Trong cấu trúc smart contract Solidity, từ khóa contract đóng vai trò y hệt như class trong lập trình hướng đối tượng (OOP). Nó gom nhóm toàn bộ dữ liệu và hành vi của hợp đồng lại với nhau thành một thực thể duy nhất.
Bên trong contract, chúng ta thường có một hàm đặc biệt gọi là constructor. Hàm này có đặc điểm là chỉ chạy duy nhất một lần vào thời điểm bạn deploy smart contract lên mạng lưới. Do đó, nó rất thích hợp để thiết lập các giá trị mặc định ban đầu hoặc gán quyền admin cho người tạo hợp đồng.
State Variables and Functions: "Brains" and "limbs" of Smart Contract
To store data permanently on the blockchain, we use state variables. Every time you change the value of this variable, you are actually changing the state of the entire Ethereum network. This process will cost gas.
Functions are where processing logic is stored. They play the role of manipulating state variables, calculating and returning results. Mastering these two components means you understand 80% of how a basic Solidity smart contract works.
Here is a quick summary of the ingredients:
| Ingredient | Main role | Note |
|---|---|---|
| Pragma | Determine version | Always place it at the beginning of the file |
| State Variables | Store data permanently | Gas costs when changing |
| Functions | Logical processing and calculations | Can read (free) or write (cost) |
5 life-changing steps for your first Smart Contract: "Hello Web3" with Remix IDE
To create a smart contract on Remix IDE, you need to create a file, write code, compile, deploy to testnet and finally interact directly with it through the interface.
Step 1: Open the Remix IDE "playground" and create a Solidity file
Cách tạo smart contract trên Remix IDE bắt đầu bằng việc truy cập vào trang web remix.ethereum.org [1]. Nhìn sang cột bên trái, bạn bấm vào biểu tượng File Explorers, chọn thư mục contracts mặc định và tạo một file mới tên là HelloWeb3.sol.
Its interface is extremely user-friendly. If you want to code faster in the future, integrating AI tools is a good idea. You can refer to the article Cursor AI editor code with AI instructions to learn how to take advantage of artificial intelligence to type code quickly in more complex projects.
Step 2: Paste the "divine" code and give a quick explanation
Below is the simplest Solidity smart contract example for you to get acquainted with. This beginner's tutorial on writing smart contracts with Solidity will use a basic greeting storage contract.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract HelloWeb3 {
string public greeting;
constructor() {
greeting = "Xin chao Web3!";
}
function setGreeting(string memory _newGreeting) public {
greeting = _newGreeting;
}
}
At Pham Hai, I always advise newbies to retype each line instead of copy-pasting to remember the syntax longer. If you want AI to automatically generate more optimal code, try applying the skills from the article Prompt engineering for developers to write code.
Step 3: Compile code - "Compile" for the Ethereum virtual machine (EVM) to understand
The EVM virtual machine (Ethereum Virtual Machine) cannot read English or your Solidity code. It only understands machine code (bytecode) and application programming interface (ABI). Therefore, you need to compile the smart contract.
Hãy chuyển sang tab "Solidity Compiler" ở thanh công cụ bên trái màn hình Remix IDE. Chọn phiên bản compiler tương ứng với pragma bạn đã khai báo (ở đây là 0.8.24) và bấm nút "Compile HelloWeb3.sol". Nếu thấy một biểu tượng dấu tick màu xanh lá hiện lên, xin chúc mừng, code của bạn không có lỗi cú pháp.
Step 4: Deploy to Testnet - "Push" your contract to the blockchain
Here is the most interesting step: deploying smart contracts on Ethereum. Switch to the "Deploy & Run Transactions" tab. In the Environment section, instead of selecting Remix VM (existing virtual environment), select "Injected Provider - MetaMask" to connect to your Metamask wallet.
Based on the latest updates as of March 2026, make sure your wallet is on the Sepolia testnet [2]. The Holesky network is currently gradually shrinking support and will close in 2025, while Sepolia is still the most standard testing environment for developers [2]. Click the "Deploy" button, confirm the transaction on the wallet and wait a few seconds for the block to be mined.
Step 5: Interact with the contract - "Chat" with the first product
Sau khi deploy thành công, hãy kéo xuống dưới cùng ở tab Deploy, bạn sẽ thấy tên contract HelloWeb3 xuất hiện. Bấm mũi tên xổ nó ra để bắt đầu tương tác smart contract.
Bạn sẽ thấy hai nút: greeting (màu xanh dương) và setGreeting (màu cam). Bấm nút xanh, nó sẽ đọc dữ liệu miễn phí và trả về "Xin chao Web3!". Nhập một câu mới vào ô cạnh nút cam, bấm chạy, duyệt giao dịch Metamask (tốn một ít gas Sepolia ETH), rồi bấm lại nút xanh. Bùm! Dữ liệu trên blockchain đã được bạn thay đổi thành công.
What happens after deployment is complete? The Road Ahead for a "Solidity-er"
After successful deployment, you need to clearly distinguish between testnet and mainnet environments, manage source code methodically, and learn more advanced tools such as Truffle, Hardhat to build a complete Dapp.
Testnet and Mainnet: What's the difference between "training ground" and large "stage"?
Testnet networks (like Sepolia) use fake ETH, completely free, a place for you to break, find bugs and experiment freely [2]. In contrast, the mainnet is the official network, where every transaction costs real money (gas fees) and data carries real asset value.
Any beginner's guide to writing smart contracts with Solidity always emphasizes extremely careful testing on the testnet. Once you push the code to the mainnet, you can no longer easily delete or modify its logic. A small error in the mainnet can mean losing millions of dollars.
Next step: Learn Truffle Suite, Hardhat and connect with Dapp
Remix IDE is great for beginners, but when you get into large-scale real projects, you'll need more powerful tools. Start learning about Truffle Suite, Ganache or Hardhat to set up a professional dev environment and write automated tests right on your personal computer.
As the project grows, storing and tracking changes to thousands of lines of code is required. Don't forget to equip yourself with knowledge through Learning Git GitHub from scratch for developers to coordinate smoothly with other team members. After mastering these tools, you can learn how to use the ethers.js library to connect the frontend interface with the contract, creating a complete Dapp.
See, writing your first smart contract is much easier than you think. With just a few steps on Remix IDE, you have entered the blockchain world. This is just the beginning, but it proves that you can completely conquer this technology. Just dabble, try and error, that's the fastest way to go from "newbie" to "pro" in this potential Web3 world.
Have you deployed your first contract yet? Try modifying the greet function so that it returns a different greeting and share the results in the comments!
Lưu ý: Thông tin trong bài viết này chỉ mang tính chất tham khảo. Để có lời khuyên tốt nhất, vui lòng liên hệ trực tiếp với chúng tôi để được tư vấn cụ thể dựa trên nhu cầu thực tế của bạn.