A comprehensive guide to deploying smart contracts on Base Mainnet
This guide covers deploying to Base Mainnet, which requires real ETH for gas fees. Always test your contracts thoroughly and ensure you understand the code before deploying. Smart contracts are immutable once deployed.
Remix is a powerful, browser-based IDE (Integrated Development Environment) for developing, deploying, and testing Ethereum smart contracts. It requires no installation and provides everything you need to start building on blockchain.
Let's create a simple storage contract. In Remix, create a new file calledSimpleStorage.solin the contracts folder.
SimpleStorage.sol
1// SPDX-License-Identifier: MIT2pragma solidity ^0.8.0;3 4/**5 * @title SimpleStorage6 * @dev Store and retrieve a single uint256 value7 */8contract SimpleStorage {9 uint256 private storedData;10 11 event DataStored(uint256 data, address indexed setter);12 13 function set(uint256 x) public {14 storedData = x;15 emit DataStored(x, msg.sender);16 }17 18 function get() public view returns (uint256) {19 return storedData;20 }21}storedData: A private variable that holds a numberset(): A function to store a new value and emit an eventget(): A view function to read the stored value (no gas cost)DataStored: An event that logs when data is storedClick on the "Solidity Compiler" icon in the left sidebar (looks like a letter S)
Select compiler version 0.8.0+ or higher
Click "Compile SimpleStorage.sol" button
If successful, you'll see a green checkmark. If there are errors, they'll be displayed below with line numbers
Enable "Auto compile" in the compiler settings to automatically compile your contract whenever you save changes.
Before deploying, you need to connect your wallet and add the Base network:
Network Name:
Base
New RPC URL:
https://mainnet.base.org
Chain ID:
8453
Currency Symbol:
ETH
Block Explorer URL:
https://basescan.org
Make sure you have ETH on Base Mainnet. You can bridge from Ethereum using bridge.base.org
Click on "Deploy & Run Transactions" icon in the left sidebar
In the "Environment" dropdown, select Injected Provider - MetaMask
MetaMask will prompt you to connect - approve the connection
Verify your account address and Base network are displayed correctly
Select "SimpleStorage" from the contract dropdown
Click the orange "Deploy" button
MetaMask will show a transaction confirmation popup
Review:
• Gas estimate (usually ~$0.01-0.10 on Base)
• Contract creation address
• Your account balance
Click "Confirm" in MetaMask
Wait for confirmation (~2 seconds on Base). Your deployed contract will appear under "Deployed Contracts" section
Your contract is now live on Base Mainnet. Copy the contract address to interact with it or share with others.
Contract verification makes your source code publicly readable on BaseScan, building trust and allowing users to understand what your contract does.
After verification, users can read your contract code directly on BaseScan and interact with it through the "Read Contract" and "Write Contract" tabs.
Once deployed, you can interact with your contract in multiple ways:
Call set() function:
Call get() function:
Visit your contract's page on basescan.org and use the "Read Contract" and "Write Contract" tabs for a web-based interface.
Visit BaseScanNow that you understand the process, try deploying your first contract using our one-click deployment or write your own custom contract.