Introduction

Want to deploy your first smart contract on Base, but not sure where to start? You’re in the right place. In this tutorial, we will guide you through the full process of creating and deploying a smart contract using Remix IDE and Hardhat, two of the most popular Ethereum developer tools. Since Base is EVM-compatible, it works just like Ethereum. That means you can write and deploy smart contracts using the same tools you already know. Plus, it’s cheaper and faster!

Let’s get started.

What You’ll Need

Step 1. Writing a Simple Smart Contract in Remix

We will start by creating a simple contract in Remix, then deploy it using Hardhat.

1. Open Remix

2. Add this code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract SimpleStorage {
    uint256 public number;

    function setNumber(uint256 _num) public {
        number = _num;
    }

    function getNumber() public view returns (uint256) {
        return number;
    }
}

This contract lets you store and retrieve a number on the blockchain.

3. Compile the Contract

SimpleStorage.sol-Compile

Done! Now let’s set up Hardhat for deployment.

Step 2. Deploying to Base Using Hardhat

1. Create a New Project Folder

mkdir base-smartcontract
cd base-smartcontract
npm init -y
npm install --save-dev hardhat
npx hardhat

Choose “Create a basic sample project”.

hardhar_install

2. Install Dependencies

npm install --save-dev @nomicfoundation/hardhat-toolbox

This command installs the Hardhat Toolbox package as a development dependency in your project.

installing-dependencies

3. Replace the Sample Contract

Go to contracts/Lock.sol and replace it with your SimpleStorage.sol code from Remix. Or create a new file

touch contracts/SimpleStorage.sol

Now you have to paste your contract code into it.

4. Configure Hardhat for Base

Edit hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");

module.exports = {
  solidity: "0.8.0",
  networks: {
    baseGoerli: {
      url: "https://sepolia.base.org",
      accounts: ["YOUR_PRIVATE_KEY"] // Don't share this!
    }
  }
};

5. Create a Deployment Script

Create a new file scripts/deploy.js

async function main() {
  const SimpleStorage = await ethers.getContractFactory("SimpleStorage");
  const contract = await SimpleStorage.deploy();
  await contract.deployed();
  console.log(`Contract deployed to: ${contract.address}`);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

6. Get Base Testnet ETH

Go to the official Base faucet and request test ETH. You can get some test ETH for deployment.

7. Deploy the Contract

npx hardhat run scripts/deploy.js --network baseSepolia

You should see the contract address once deployed!

Deploy.png

Now your contract is live on the Base testnet, and you can interact with it using the address and functions like setNumber() or getNumber().

Final Thoughts

Deploying smart contracts on Base is simple, fast, and cost-effective, especially for Ethereum developers. With tools like Remix for quick contract creation and Hardhat for powerful local development, you can launch dApps, tokens, or NFTs on Base in no time. Since Base supports the same EVM standards, you don’t have to learn anything new. Plus, your users benefit from lower gas fees and faster performance.