Back to Medical Records

Deploy with Remix IDE

A comprehensive guide to deploying smart contracts on Base Mainnet

Important Notice

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.

1

Introduction to Remix IDE

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.

Key Features:

  • Built-in Solidity compiler with multiple version support
  • Direct wallet integration (MetaMask, Coinbase Wallet, etc.)
  • Real-time error detection and debugging tools
  • Gas estimation and transaction simulation
Open Remix IDE
2

Writing a Smart Contract

Let's create a simple storage contract. In Remix, create a new file calledSimpleStorage.solin the contracts folder.

SimpleStorage.sol

1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.0;
3
4/**
5 * @title SimpleStorage
6 * @dev Store and retrieve a single uint256 value
7 */
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}

Code Explanation:

  • storedData: A private variable that holds a number
  • set(): A function to store a new value and emit an event
  • get(): A view function to read the stored value (no gas cost)
  • DataStored: An event that logs when data is stored
3

Compiling the Contract

  1. 1

    Click on the "Solidity Compiler" icon in the left sidebar (looks like a letter S)

  2. 2

    Select compiler version 0.8.0+ or higher

  3. 3

    Click "Compile SimpleStorage.sol" button

  4. 4

    If successful, you'll see a green checkmark. If there are errors, they'll be displayed below with line numbers

Pro Tip:

Enable "Auto compile" in the compiler settings to automatically compile your contract whenever you save changes.

4

Connecting Your Wallet

Before deploying, you need to connect your wallet and add the Base network:

Adding Base Network to MetaMask:

  1. 1.Open MetaMask and click on the network dropdown at the top
  2. 2.Click "Add Network" → "Add a network manually"
  3. 3.Enter the following details:

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

5

Deploying to Base Mainnet

  1. 1

    Click on "Deploy & Run Transactions" icon in the left sidebar

  2. 2

    In the "Environment" dropdown, select Injected Provider - MetaMask

  3. 3

    MetaMask will prompt you to connect - approve the connection

  4. 4

    Verify your account address and Base network are displayed correctly

  5. 5

    Select "SimpleStorage" from the contract dropdown

  6. 6

    Click the orange "Deploy" button

  7. 7

    MetaMask will show a transaction confirmation popup

    Review:

    • Gas estimate (usually ~$0.01-0.10 on Base)

    • Contract creation address

    • Your account balance

  8. 8

    Click "Confirm" in MetaMask

  9. 9

    Wait for confirmation (~2 seconds on Base). Your deployed contract will appear under "Deployed Contracts" section

Success!

Your contract is now live on Base Mainnet. Copy the contract address to interact with it or share with others.

6

Verifying on BaseScan

Contract verification makes your source code publicly readable on BaseScan, building trust and allowing users to understand what your contract does.

Manual Verification Steps:

  1. 1.Go to your contract address on basescan.org
  2. 2.Click "Contract" tab → "Verify and Publish"
  3. 3.Select "Solidity (Single file)" as compiler type
  4. 4.Choose the same compiler version used in Remix
  5. 5.Select MIT license
  6. 6.Paste your complete Solidity code
  7. 7.Click "Verify and Publish"

After verification, users can read your contract code directly on BaseScan and interact with it through the "Read Contract" and "Write Contract" tabs.

7

Interacting with Your Contract

Once deployed, you can interact with your contract in multiple ways:

In Remix IDE:

  • Expand your deployed contract in the "Deployed Contracts" section
  • Blue buttons are read functions (free, no gas)
  • Orange buttons are write functions (cost gas)

Example Interactions:

Call set() function:

  1. 1. Enter a number next to the "set" button
  2. 2. Click the button
  3. 3. Confirm the transaction in MetaMask
  4. 4. Wait ~2 seconds for confirmation

Call get() function:

  1. 1. Click the "get" button
  2. 2. The stored value appears immediately (no transaction needed)

On BaseScan:

Visit your contract's page on basescan.org and use the "Read Contract" and "Write Contract" tabs for a web-based interface.

Visit BaseScan

Ready to Deploy?

Now that you understand the process, try deploying your first contract using our one-click deployment or write your own custom contract.