Enigmatic Aura
TwitterMediumGithub
  • Welcome
  • 101-CRYPTO-WEB3
    • [101] Crypto and Web3 Basics
    • [101] Linux Commands
  • NEW NODE & TESNET
    • Aztec Public Testnet Guide
  • Node Validator
    • Sonaric AI Node
    • Zenrock Node
      • Update Zenrock Node
    • BrinX AI Node Validator
      • Worker Node Setup
      • Relay Node Setup
    • Drosera CLI Node Guide
  • Testnet Airdrop
    • Monad Testnet Guide
    • Sunrise Testnet v2
    • Inkonchain - The Break
    • Plaza Finance - Testnet
    • Cysic Incentivized Testnet
    • Crypto Faucet List
    • Abstract Chain's L2 Testnet
    • DEPIN - Project
      • Dawn
      • Teneo Node Extension
      • OpenLayer
        • Code
      • Gradient Network
      • Grass Stage 2: Capturing the Web
    • Base Learn - Testnet
      • Deploying Smart Contracts
        • How to Deploy
        • Testnet Base Learn
        • Source Code
      • Join Community
    • Incentivized Testnet - Multipli's
    • Yala Testnet
      • Getting Started on Yala Testnet
      • How to Set Up Your Wallet and Claim the Faucet
      • Testnet Tasks
      • Additional Resources
      • Other Tasks
    • Unichain Testnet
      • Wallet Setup & Faucet
      • Bridge
      • Deploy , Swap & Add LP
      • Additional Tasks
    • Rise Chain
  • Retrodrop
    • Huma Finance, OpenEden & SuperStacks
Powered by GitBook
On this page
  1. Testnet Airdrop
  2. Base Learn - Testnet
  3. Deploying Smart Contracts

How to Deploy

Remix or Hardhat

PreviousDeploying Smart ContractsNextTestnet Base Learn

Last updated 7 months ago

1. Using Remix

Step 1: Set Up Metamask for Base Sepolia

  • Open Metamask and add a new network.

  • Network details:

    • Network Name: Base Sepolia

    • RPC URL: https://sepolia.base.org

    • Chain ID: 11155111

    • Symbol: ETH

    • Block Explorer: https://sepolia.etherscan.io

Step 2: Get Sepolia ETH

  • Go to .

  • Connect your wallet and request test ETH to cover gas fees.

Step 3: Deploying with Remix

  1. Open Remix IDE.

  2. Create a new file and write or paste your Solidity contract. Example:

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

contract SimpleStorage {
    uint256 public storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}
  1. Compile the contract using the Solidity compiler.

    • Ensure the Solidity version matches the one in the code.

  2. Switch to the Deploy & Run Transactions tab.

    • Select Injected Web3 as the environment, connecting it to Metamask.

  3. Click Deploy and confirm the transaction in Metamask.

Step 4: Verify Deployment

  • Check the status on Base Sepolia Explorer using your wallet address or transaction hash.


2. Using Hardhat

Step 1: Install Node.js and Hardhat

  1. Open your terminal and run the following command to install Hardhat:

bashCopy codenpm install --save-dev hardhat

Step 2: Create a Hardhat Project

  1. Initialize your Hardhat project:

bashCopy codenpx hardhat
  1. Choose "Create an empty hardhat.config.js" for simplicity.

Step 3: Write the Contract

Create a file SimpleStorage.sol in the contracts folder with this code:

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

contract SimpleStorage {
    uint256 public storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}

Step 4: Configure Hardhat for Base Sepolia

In your hardhat.config.js file, add the Base Sepolia network:

javascriptCopy coderequire('@nomiclabs/hardhat-ethers');
require('dotenv').config();

module.exports = {
  solidity: "0.8.0",
  networks: {
    sepolia: {
      url: 'https://sepolia.base.org',
      accounts: [`0x${process.env.PRIVATE_KEY}`]
    }
  }
};

Make sure to add your wallet private key in a .env file:

bashCopy codePRIVATE_KEY=your_wallet_private_key_here

Step 5: Deploy the Contract

Create a deploy.js file inside the scripts folder:

javascriptCopy codeasync function main() {
  const SimpleStorage = await ethers.getContractFactory('SimpleStorage');
  const simpleStorage = await SimpleStorage.deploy();
  
  console.log('Contract deployed to:', simpleStorage.address);
}

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

Step 6: Deploy via Hardhat

Run the following command to deploy your contract to Base Sepolia:

bashCopy codenpx hardhat run scripts/deploy.js --network sepolia

Step 7: Verify Deployment

Check your contract on the Base Sepolia Explorer.

Install Node.js from .

Base Sepolia Faucet
here