# How to Deploy

#### **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 [Base Sepolia Faucet](https://sepoliafaucet.com).
* 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:

```solidity
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;
    }
}
```

3. Compile the contract using the Solidity compiler.
   * Ensure the **Solidity version** matches the one in the code.
4. Switch to the **Deploy & Run Transactions** tab.
   * Select **Injected Web3** as the environment, connecting it to Metamask.
5. 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. Install **Node.js** from [here](https://nodejs.org/).
2. Open your terminal and run the following command to install Hardhat:

```bash
bashCopy codenpm install --save-dev hardhat
```

**Step 2: Create a Hardhat Project**

1. Initialize your Hardhat project:

```bash
bashCopy codenpx hardhat
```

2. 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:

```solidity
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:

```javascript
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:

```bash
bashCopy codePRIVATE_KEY=your_wallet_private_key_here
```

**Step 5: Deploy the Contract**

Create a `deploy.js` file inside the `scripts` folder:

```javascript
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:

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

**Step 7: Verify Deployment**

Check your contract on the Base Sepolia Explorer.
