Stepping into Web3 development can feel intimidating. With terms like gas fees, smart contracts, decentralization, and testnets flying around, it is easy to get overwhelmed. But the truth is, writing your very first decentralized application (dApp) backend is much simpler than you think.
In this guide, I’ll walk you through how to write, compile, and deploy your first basic smart contract using Solidity and the Remix IDE. By the end of this post, you’ll have a working smart contract running on a blockchain environment and the confidence to take your next steps in Web3.
What You Need Before You Start
Before diving into the code, you’ll want to have a couple of free tools ready:
- A Web Browser: Chrome, Brave, or Firefox.
- MetaMask Extension: Installed in your browser (though for today's local test, we won't even need real funds).
- Remix IDE: Accessible right in your browser at remix.ethereum.org (no installation required!).
Step 1: Set Up Your Workspace in Remix IDE
Remix is an online Integrated Development Environment (IDE) built specifically for writing Solidity code. It’s the fastest way to get started without messing around with complex local node configurations.
- Head over to remix.ethereum.org.
- On the left-hand sidebar, navigate to the File Explorers tab.
- Under the
folder, create a new file namedcontracts
.SimpleStorage.sol
Step 2: Write Your First Smart Contract
We are going to write a simple smart contract that allows anyone to store a number on the blockchain and retrieve it later.
Paste the following code into your
SimpleStorage.sol file:
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; contract SimpleStorage { // State variable to store a number uint256 private storedData; // Event to log when data is updated event DataStored(uint256 newValue); // Function to store a new value function set(uint256 x) public { storedData = x; emit DataStored(x); } // Function to retrieve the stored value function get() public view returns (uint256) { return storedData; } }








Latest comments
0