L10: Solidity Basics
Set up your Solidity development environment, write and compile your first contracts, and deploy them to the Sepolia testnet using Remix IDE.
Companion Colab notebook
For a Python-driven walkthrough of the same three contracts (SimpleStorage, ERC-20, Voting) compiled and deployed on an in-process EVM, open 10_solidity_workshop.ipynb in Colab. No wallet, no faucet, no testnet required.
Prefer the slides first? Open the Workshop walk-through slides (10 frames; teaches the actual Solidity 0.8.20 code in the notebook, the compile-deploy-call loop, and what to watch when you run the cells).
Tool Overview
What you will use in this lesson
- Remix IDE — browser-based Solidity editor, compiler, and deployer (no installation needed)
- MetaMask — browser wallet for signing transactions and switching networks
- Sepolia Faucet — source of free testnet ETH for paying gas fees
Guided Activities
- Open remix.ethereum.org in your browser. No login or installation required.
- In the left panel, click the File Explorer icon (top icon, looks like two pages).
- Click the + icon next to "contracts" to create a new file. Name it
SimpleStorage.sol. - Paste the following starter contract into the editor:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract SimpleStorage {
uint256 public storedNumber;
function store(uint256 _number) public {
storedNumber = _number;
}
function retrieve() public view returns (uint256) {
return storedNumber;
}
}
- Click the Solidity Compiler icon in the left panel (looks like an "S" with an arrow).
- Set the compiler version to 0.8.20 or newer from the dropdown.
- Click Compile SimpleStorage.sol. A green checkmark means success.
Reflection question: What does
pragma solidity ^0.8.20 mean? Why is it important to pin a minimum compiler version in production contracts?
- Click the Deploy & Run Transactions icon in the left panel (looks like an Ethereum diamond with an arrow).
- Under Environment, select Remix VM (Cancun) — this is an in-browser blockchain, no real ETH needed.
- Confirm that
SimpleStorageis selected in the Contract dropdown. - Click the orange Deploy button. The contract appears under "Deployed Contracts" at the bottom.
- Expand the deployed contract. You will see two buttons:
storeandretrieve. - Type a number (e.g.,
42) in the input box next tostore, then click store. - Click retrieve — the stored number appears below the button.
Reflection question: The
store button is orange (state-changing transaction) and retrieve is blue (read-only call). Why do read-only calls cost no gas, but writes do?
3
Get Testnet ETH from the Sepolia Faucet
Tool: Sepolia Faucet- Install the MetaMask browser extension if you have not already. Create or import a wallet.
- In MetaMask, click the network selector at the top and choose Sepolia Test Network. (Enable test networks in Settings → Advanced if not visible.)
- Copy your wallet address from MetaMask (click your account name at the top).
- Visit one of these Sepolia faucets:
- sepoliafaucet.com — requires Alchemy account (free)
- faucet.quicknode.com/ethereum/sepolia — requires QuickNode account (free)
- faucets.chain.link/sepolia — Chainlink faucet, no account needed
- Paste your wallet address into the faucet and request test ETH. It should arrive within 30 seconds to 2 minutes.
- Confirm the balance appears in MetaMask on the Sepolia network.
Reflection question: Why do testnets exist? What would happen if developers had to pay real ETH for every contract deployment during development?
- In Remix, go back to Deploy & Run Transactions.
- Under Environment, select Injected Provider - MetaMask. MetaMask will pop up asking for permission — click Connect.
- Confirm the network shown in Remix matches Sepolia (chain ID 11155111). If not, switch networks in MetaMask first.
- With
SimpleStorageselected, click Deploy. MetaMask will show a transaction confirmation with a gas estimate. - Click Confirm in MetaMask. Wait 15–30 seconds for the transaction to be mined.
- Once deployed, copy the contract address shown in Remix under "Deployed Contracts".
- Go to sepolia.etherscan.io and paste your contract address to see it on the block explorer.
Reflection question: Your contract address on Sepolia is permanent and publicly visible. What does this tell you about smart contract privacy? Are there ways to deploy private contracts?
- Click the Plugin Manager icon in the left panel (looks like a plug). This lists all available Remix plugins.
- Find Solidity Unit Testing and click Activate. This adds a test runner to Remix.
- In the file explorer, create a new file
SimpleStorage_test.solin thetests/folder and paste:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "remix_tests.sol";
import "../contracts/SimpleStorage.sol";
contract SimpleStorageTest {
SimpleStorage s;
function beforeEach() public {
s = new SimpleStorage();
}
function testStoreAndRetrieve() public {
s.store(99);
Assert.equal(s.retrieve(), 99, "Retrieved value should be 99");
}
}
- Open the Solidity Unit Testing panel and click Run. A passing test shows a green checkmark.
- Try the Gas Profiler plugin: activate it, run your contract functions, and observe gas costs reported per function call.
Reflection question: The unit test deploys a fresh contract in
beforeEach(). Why is test isolation important in smart contract testing? What could go wrong if tests shared a single contract instance?