# Overview

## Welcome to the Blast Documentation!

#### Overview

Welcome to the official documentation for Blast, a blockchain solution utilizing the innovative zkEVM technology pioneered by Polygon zkEVM rollup. Blast focuses on scaling and enhancing blockchain interactions through the One World Chain, a Layer 1 blockchain designed to be more accessible, responsive, and capable of supporting a larger number of users compared to traditional blockchain platforms.

#### **What is Blast Building?**

Blast is not just adopting but also enhancing the zkEVM technology to scale blockchain applications effectively. As blockchain technology becomes increasingly foundational to decentralized applications, the need for more efficient, cost-effective solutions becomes apparent. This is particularly crucial as higher costs and slower transaction times could impede wider adoption.

Blast utilizes zero-knowledge proofs, a form of cryptography that allows for privacy and complete transparency in transactions. The technology enables the One World Chain to ensure all network activities are secure and compliant with established blockchain protocols, offering unparalleled security, decentralization, and resistance to censorship.

Our adoption of zkEVM technology means that Blast can provide Ethereum-compatible scalability solutions that maintain rigorous security standards and improve transaction efficiency.

#### **Using Blast Today**

The Blast mainnet is live! It operates using the One World Chain, with $OWCT (One World Chain Tokens) as its native currency. Here’s how you can engage with the platform:

* **Explore**: Visit the Blast Chain Block Explorer at [https://blastchain.org](https://blastchain.org/) to view live transactions and network status.
* **Transact**: Perform transactions using OWCT, which are used for paying transaction fees and conducting operations across the network.
* **Develop and Deploy**: Utilize our detailed developer guides to build and deploy decentralized applications (DApps) on the Blast network.

#### **The Future of Blast**

While the Blast mainnet is operational, our mission continues with a focus on expanding the capabilities and decentralizing the infrastructure of our network. Stay informed about our progress and join the community discussions via our blog, Discord, or Twitter.


# User Guide


# Setup

#### **Wallet Configuration**

To interact with decentralized applications (DApps) on Blast zkEVM, a compatible wallet like Metamask is essential. Blast's bridge supports Metamask exclusively due to its wide adoption and strong security features.

#### **Metamask Installation**

Download and install Metamask from their [official website](https://metamask.io/). This wallet facilitates interaction with Ethereum and Ethereum-compatible blockchains, such as Blast zkEVM.

#### **Network Configuration for Metamask**

Configure your Metamask to connect with the Blast zkEVM network by following these steps:

1. **Open Metamask**: Click on the Metamask extension on your browser.
2. **Access Network Settings**: Click on the chain drop down icon on the metamask popup.
3. **Add Network**: Navigate to "Add a custom Network"
4. **Enter Network Details**: Input the following details to connect to the Blast zkEVM:
   * **Network Name**: Blast Chain
   * **New RPC URL**: `https://zkevmrpc.blastchain.org`
   * **Chain ID**: 238
   * **Currency Symbol**: OWCT
   * **Block Explorer URL**: `https://blastchain.org/`
5. **Save and Connect**: Click "Save" to add the network. Metamask will automatically switch to the Blast Chain.


# Bridge

#### **Overview**

Visit our Blast bridge to easily and securely transfer assets between the One World Chain (L1) and Blast (L2). The Blast Bridge supports both deposit and withdrawal operations, enabling trustless asset transfers across layers.

### **Depositing OWCT from One World Chain to Blast Chain**

**Step-by-Step Guide**

1. **Adding the Blast Network to Metamask**
   * Go to the [Blast Bridge](https://bridge.blastchain.org) website and click **Add to Metamask** to automatically configure your wallet for the Blast Chain.
2. **Connect Your Wallet**
   * Click on **Connect a wallet** and select Metamask. Follow the prompts to log in.
3. **Initiate a Deposit**
   * Choose 'From' One World Chain and 'To' Blast Chain.
   * Enter the amount of OWCT you wish to transfer and click **Continue**.
4. **Confirm the Transfer**
   * Review the transaction details, including the estimated gas fee.
   * Click **Bridge** to submit the transaction.
5. **Transaction Monitoring**
   * Track the transaction in the **Activity** tab. You will need to wait for the validity proof to be confirmed.

### **Withdrawing OWCT from Blast Chain to One World Chain**

**Step-by-Step Guide**

1. **Connect Your Wallet**
   * Ensure your wallet is connected to the Blast Chain.
2. **Initiate a Withdrawal**
   * Select 'From' Blast Chain and 'To' One World Chain.
   * Enter the amount of OWCT you wish to withdraw.
   * Click **Continue** to proceed.
3. **Execute the Bridge Transfer**
   * Confirm the details of your withdrawal, including the estimated gas fee.
   * Click **Bridge** to initiate the withdrawal.
4. **Finalizing the Transaction**
   * After bridging, monitor the transaction under the **Activity** tab.
   * Once the initial transaction is processed, click **Finalize** to complete the transfer and receive your OWCT on the One World Chain.

#### **Additional Information**

* Transactions may take time to finalize based on network congestion and the underlying technology.
* Always ensure you are connected to the correct network (One World Chain or Blast Chain) depending on the direction of your transaction.

{% hint style="info" %}
This guide provides a comprehensive overview of how to use the Blast Bridge for transferring OWCT between the One World Chain and Blast Chain. Please ensure all steps are followed correctly to guarantee a smooth transaction process. If you encounter any issues, consult the help section on the Bridge website or contact support.
{% endhint %}


# Transfer Tokens

#### **Overview**

Transferring tokens on the Blast Chain Mainnet using Metamask is a straightforward process. This guide will walk you through the steps needed to send tokens efficiently and securely.

#### **Sending Tokens Using Metamask**

Follow these steps to transfer tokens within the Blast Chain Mainnet:

**1. Open Your Metamask Wallet**

* Ensure your Metamask is set to the Blast Chain Mainnet. This should have been configured when you first connected to the Blast network.

**2. Initiate the Transfer**

* Click the **Send** button on the main page of your Metamask wallet.
* Enter the recipient's address into the address field. Be sure to double-check the address to prevent any errors.

**3. Select the Token and Amount**

* Choose the token you wish to send from the **Asset** dropdown menu.
* Type in the amount you want to transfer. Make sure you have enough balance for both the token amount and the transaction fees in OWCT.

**4. Confirm the Transaction**

* After entering the details, click **Next** to review the transaction summary.
* Review the transaction fees and total amount being sent. When ready, click **Confirm** to execute the transfer.

**5. Check Transaction Status**

* Once submitted, you can monitor the transaction in the **Activity** tab of your Metamask wallet.
* The transaction status will update once it's successfully processed on the network.

> **Tips for a Successful Transaction**
>
> * **Sufficient Fees**: Always ensure that you have enough OWCT in your wallet to cover the network fees.
> * **Address Accuracy**: Verify the recipient's address. Sending to an incorrect address may result in irreversible loss of tokens.
> * **Network Activity**: Transaction times can vary based on the network's activity. During high traffic periods, transactions may take longer to process.


# Blast Mainnet

<table data-full-width="false"><thead><tr><th width="240">Network Name</th><th width="244">Blast Chain</th><th valign="middle">One World Chain</th></tr></thead><tbody><tr><td>RPC URL</td><td><a href="https://zkevmrpc.blastchain.org">https://zkevmrpc.blastchain.org</a></td><td valign="middle"><a href="https://mainnet-rpc.oneworldchain.org
">https://mainnet-rpc.oneworldchain.org</a></td></tr><tr><td>Chain ID</td><td>238</td><td valign="middle">309075</td></tr><tr><td>Currency Symbol</td><td>OWCT</td><td valign="middle">OWCT</td></tr><tr><td>Block Explorer URL</td><td><a href="https://blastchain.org">https://blastchain.org</a></td><td valign="middle"><a href="https://mainnet.oneworldchain.org/">https://mainnet.oneworldchain.org/</a></td></tr></tbody></table>


# Developer Quickstart

With Blast Chain, your favorite tools for building and testing smart contracts just work.

Since Blast is bytecode equivalent with the EVM, you’ll just need to point your favorite builder tools at a Blast RPC Provider.

If you run into any issues, please send it to us via email <blast@blastchain.org>.

### Acquiring OWCT  <a href="#acquiring-ether" id="acquiring-ether"></a>

Blast Chain uses OWCT as its native currency, which is required to pay transaction fees for deploying and interacting with the network.

To start building on Blast Chain, you can directly engage with the Blast Chain Mainnet, as there is no separate testnet environment. Ensure you have OWCT available in your wallet to cover transaction costs. You can obtain OWCT through various exchanges or from peer-to-peer transactions.

For a step-by-step guide on how to configure your environment and begin transactions, refer to the User Guide’s [Setup](https://docs.blastchain.org/getting-started/user-guide/setup) page.

Once you’re ready to deploy on the Blast Chain Mainnet, all operations can be conducted directly within this environment. There is no need to bridge assets from another chain, simplifying the process and enhancing user convenience.

### Network Configuration

<table data-full-width="false"><thead><tr><th width="240">Network Name</th><th width="244">Blast Chain</th><th valign="middle">One World Chain</th></tr></thead><tbody><tr><td>RPC URL</td><td><a href="https://zkevmrpc.blastchain.org">https://zkevmrpc.blastchain.org</a></td><td valign="middle"><a href="https://mainnet-rpc.oneworldchain.org
">https://mainnet-rpc.oneworldchain.org</a></td></tr><tr><td>Chain ID</td><td>238</td><td valign="middle">309075</td></tr><tr><td>Currency Symbol</td><td>OWCT</td><td valign="middle">OWCT</td></tr><tr><td>Block Explorer URL</td><td><a href="https://blastchain.org">https://blastchain.org</a></td><td valign="middle"><a href="https://mainnet.oneworldchain.org/">https://mainnet.oneworldchain.org/</a></td></tr></tbody></table>

### Configure your tooling <a href="#configure-your-tooling" id="configure-your-tooling"></a>

{% hint style="info" %}
For setting up tooling to verify a smart contract deployment, see [Verifying Smart Contracts](/verifying-smart-contracts).
{% endhint %}

### Hardhat <a href="#hardhat" id="hardhat"></a>

Modify your Hardhat config file `hardhat.config.ts` to point at the Blast Chain public RPC.

```javascript

...

const config: HardhatUserConfig = {
  ...
  networks: {
    blastChain: {
      url: "https://zkevmrpc.blastchain.org/" || "",
      accounts:
        process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
    },
  },
};

...

```

### Remix Web IDE <a href="#remix-web-ide" id="remix-web-ide"></a>

After compiling your contracts, the easiest way to deploy using Remix is by [setting up Metamask](/getting-started/user-guide/setup), then selecting the **Blast Mainnet** network.

<figure><img src="https://1962852186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiLoY4mJeB8yAuA98KPTf%2Fuploads%2FqVVey7IEZS1hkkehmfwr%2Fimage.png?alt=media&amp;token=4c44f315-a506-4874-aa1b-61d48082de54" alt=""><figcaption></figcaption></figure>

Now, in the “Deploy and Run Transactions” tab, use the “Environment” drop-down and select “Injected Provider - MetaMask.”<br>

<figure><img src="https://1962852186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiLoY4mJeB8yAuA98KPTf%2Fuploads%2FVczYaESFZVXhwd673O0E%2Fimage.png?alt=media&amp;token=f560583e-a3df-4ec1-99c6-0ac35734133f" alt=""><figcaption></figcaption></figure>

Connect your wallet and select the **Blast Mainnet**. Your account should be selected automatically in Remix, and you can click “Deploy.”

### Truffle

Assuming you already have a Truffle environment setup, go to the Truffle [configuration file](https://trufflesuite.com/docs/truffle/reference/configuration/), `truffle.js`. Make sure to have installed HDWalletProvider: `npm install @truffle/hdwallet-provider@1.4.0`

```javascript
const HDWalletProvider = require("@truffle/hdwallet-provider")
...
module.exports = {
  networks: {
    blastChain: {
      provider: () =>
        new HDWalletProvider(process.env.PRIVATE_KEY, "https://zkevmrpc.blastchain.org/"),
      network_id: '*',
    },
  }
}
```

### ethers.js <a href="#ethersjs" id="ethersjs"></a>

Setting up a Blast Chain provider in an `ethers` script:

```javascript
import { ethers } from "ethers"

const provider = new ethers.providers.JsonRpcProvider("https://zkevmrpc.blastchain.org/")
```

### **Configure Hardhat**

In the `packages/hardhat/hardhat.config.js` file, you’ll add the network and select it as the default network.

```javascript
...
//
// Select the network you want to deploy to here:
//
const defaultNetwork = "blastChain";
...
module.exports = {
...
  networks: {
...
          blastChain: {
            url: "https://zkevmrpc.blastchain.org/",
            accounts: {
              mnemonic: mnemonic(),
            },
          },
  }
...
}
```

Be sure to fund the deployment wallet as well! Run `yarn generate` to create the wallet and `yarn account` to check its funds. Once funded, run `yarn deploy --network` blastChain to deploy on the Blast Chain.


# Interact with a node RPC

If you’re a new Web3 developer, you might find that running your own full node is unnecessary, especially when you can connect to a public RPC service that simplifies the process.

Most developers prefer using a public RPC provider as it handles node requests and returns responses automatically. This is generally the fastest way to start developing, as it eliminates the complexities of managing your own node.

**Send Your First Blockchain Request**

To begin, ensure you have a Web3-enabled environment set up, such as a project configured with Web3.js or Ethers.js. Here's how to make your first blockchain request using the public RPC endpoint for Blast Chain:

#### Making a cURL Request

You can interact with the Blast blockchain using the JSON-RPC directly from your command line. For manual requests, use POST requests with the JSON-RPC. You'll need to include the `Content-Type: application/json` header and your query in the POST body with the following fields:

* `jsonrpc`: This specifies the JSON-RPC version, which is currently 2.0.
* `method`: The API method you wish to call. See Blast API reference for details.
* `params`: A list of parameters to pass to the method.
* `id`: Your request's ID, which will be echoed in the response to help track which request the response corresponds to.

Here’s an example command to run from your command line to retrieve the current gas price:

```bash
curl https://zkevmrpc.blastchain.org \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0", "method":"eth_gasPrice", "params":[], "id":1}'
```

#### Results

You should receive a response similar to this:

```json
{ "id": 1, "jsonrpc": "2.0", "result": "0x77359400" }  // This is an example gas price.
```

This demonstrates a basic interaction with the Blast blockchain via the public RPC. You can expand upon this by integrating the RPC calls into your applications using a library like Web3.js or Ethers.js to automate interactions and create more complex functionalities.

Here's the revised section with the correct RPC URL for the Blast Chain:

***

**Other Web3 Libraries**

There are several Web3 libraries available that facilitate interaction with blockchain networks, including the Blast Chain. Below are instructions for configuring some of these libraries to connect to the Blast Chain using its public RPC:

#### **Python with Web3.py**

```python
# Setup: pip install web3
from web3 import Web3
web3 = Web3(Web3.HTTPProvider("https://zkevmrpc.blastchain.org"))
```

#### **Java with Web3j**

```java
// Setup: curl -L get.web3j.io | sh
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;

Web3j web3 = Web3j.build(new HttpService("https://zkevmrpc.blastchain.org"));
```

#### **JavaScript with Ethers.js**

```javascript
// Setup: npm install ethers
const { ethers } = require("ethers");
const customHttpProvider = new ethers.providers.JsonRpcProvider("https://zkevmrpc.blastchain.org");
```

#### **JavaScript with Web3.js**

```javascript
// Setup: npm install web3
const Web3 = require('web3');
const web3 = new Web3("https://zkevmrpc.blastchain.org");
```

These code snippets provide the necessary setup to connect various popular Web3 libraries to the Blast Chain using its official public RPC endpoint. Choose the library that aligns with your development preferences and start building on Blast Chain effectively.


# Verifying Smart Contracts

### Using Developer Tools <a href="#using-developer-tools" id="using-developer-tools"></a>

Most smart contract tooling has plugins for verifying your contracts easily on Blast chain explorer.

Blast Chain Explorer API:  [https://blastchain.org/api](https://blastchain.org/api-docs)

### Hardhat <a href="#hardhat" id="hardhat"></a>

Modify `hardhat.config.ts` to point to Blast Chain’s RPC and block explorer API.

For example, the config for Blast Chain will look like this:

```javascript
...

const config: HardhatUserConfig = {
  ...
  networks: {
    blastChain: {
      url: 'https://zkevmrpc.blastchain.org' || '',
      accounts:
        process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
    },
  },
  etherscan: {
    apiKey: {
      blastChain: <YOUR API KEY>,
    },
    customChains: [
      {
        network: 'blastChain',
        chainId: 238,
        urls: {
          apiURL: 'https://blastchain.org/api',
          browserURL: 'https://blastchain.org/',
        },
      },
    ],
  },
}

...
```

Now you can verify the smart contract by running the following command.

```
npx hardhat verify --network blastChain <contract address> <space separated constructor parameters>

```

For example, this is how a smart contract that receives two uint parameters in the constructor should look:

```
npx hardhat verify --network blastChain 0xD9885478bd717189cC3Fbe7B9020F27fae7Ac76F 123 456
```

{% hint style="warning" %}
You may receive an error stating `etherscan.apiKey.trim is not a function`. If so, you need to update `@nomiclabs/hardhat-etherscan` to be able to support custom chains. Try running `npm update @nomiclabs/hardhat-etherscan`
{% endhint %}


# Contract Deployment Tutorial

The Blast Chain Mainnet allows anyone to deploy a smart contract. In this tutorial, you will learn how to deploy a contract on Blast using common tools for developing on Ethereum-compatible networks. This demo repo illustrates contract deployment with Hardhat and Foundry.

{% hint style="success" %}
**Got OWCT?**

Before you start deploying your contract, make sure you have OWCT in your wallet to cover transaction fees. OWCT can be acquired through various exchanges or peer-to-peer transactions.
{% endhint %}

### Initial setup <a href="#initial-setup" id="initial-setup"></a>

Add the Blast Chain to your Metamask wallet. Ensure you have some OWCT for transaction fees, which you can obtain through an exchange or peer-to-peer transaction.

Clone the repo using the command below:

```bash
git clone https://github.com/oceans404/fullstack-zkevm
```

Install dependencies and start the React app (you can copy all three lines in one go):

```bash
cd fullstack-zkevm
npm install
npm start
```

Correct installation opens up the Counter App at localhost:3000. You can test it by clicking on the +1 button several times.

Back in the CLI, install the necessary dependencies:

```bash
npm install ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers dotenv
```

Populate the `.env.sample` file with your `ACCOUNT_PRIVATE_KEY`.

**How to get your private key in MetaMask:**

Ensure that you handle your private key securely to avoid exposing your assets to theft.

Copy the contents of the `.env.sample` file to a new `.env` file:

```bash
cp .env.sample .env
```

### Hardhat smart contract

Next is the initialization of a project using Hardhat. Hardhat cannot initialize a sample project if there is an existing README file. To avoid clashes, rename any existing `README.md` temporarily before initializing Hardhat.

```bash
mv README.md README-tutorial.md
```

* Initialize a project with Hardhat: `npx hardhat init`.
* Next, (… *To avoid failure … please go slow with this cli dialogue*…),

  The aim here is to achieve the following outcome:

  ![Figure \_](https://docs.polygon.technology/img/zkEVM/zkv-proj-created-outcome.png)

  So then,
* Press `<ENTER>` to set the project root.
* Press `<ENTER>` again to accept addition of `.gitignore`.
* Type `n` to reject installing `sample project's dependencies`.

  The idea here is to postpone installing dependencies to later steps due to a possible version-related bug.
* Open the `hardhat.config.js` file and paste the below code:

  ```javascript
  require("dotenv").config();
  require("@nomicfoundation/hardhat-toolbox");

  /** @type import('hardhat/config').HardhatUserConfig */
  module.exports = {
  solidity: "0.8.9",
  paths: {
      artifacts: "./src",
  },
  networks: {
      blastChain: {
      url: `https://zkevmrpc.blastchain.org`,
      accounts: [process.env.ACCOUNT_PRIVATE_KEY],
      },
  },
  };
  ```

  Note that a different path to artifacts is added so that the React app can read the contract ABI within the `src` folder.

### Add scripts

* Create a new file, in the contracts folder, named `Counter.sol`: `touch contracts/Counter.sol`.
* Copy the below code and paste it in the Counter contract code:

  ```javascript
  //SPDX-License-Identifier: MIT
  pragma solidity ^0.8.9;

  contract Counter {
  uint256 currentCount = 0;

      function increment() public {
          currentCount = currentCount + 1;
      }

      function retrieve() public view returns (uint256){
          return currentCount;
      }
  }
  ```
* Create a new file in the scripts folder `deploy-counter.js`: `touch scripts/deploy-counter.js`.
* Add the code below to the `deploy-counter.js` file:

  ```javascript
  const hre = require("hardhat");

  async function main() {
      const deployedContract = await hre.ethers.deployContract("Counter");
      await deployedContract.waitForDeployment();
      console.log(
          `Counter contract deployed to https://blastchain.org/address/${deployedContract.target}`
      );
  }

  main().catch((error) => {
      console.error(error);
      process.exitCode = 1;
  });
  ```
* Before compiling the contract, you need to install the toolbox. You may need to change directory to install outside the project. Use this command:

  ```bash
  npm install --save-dev @nomicfoundation/hardhat-toolbox
  ```
* Compile your contract code (i.e., go back to the project root in the CLI):

  ```bash
  npx hardhat compile
  ```
* Now run the scripts:

  ```bash
  npx hardhat run scripts/deploy-counter.js --network blastChain
  ```

  ​Here’s an output example:

  `Counter contract deployed to https://blastchain.org/address/0x5FbDB2315678afecb367f032d93F642f64180aa3`

### Update frontend <a href="#update-frontend" id="update-frontend"></a>

The next step is to turn `Counter.sol` into a dApp by importing the `ethers` and the `Counter` file, as well as logging the contract’s ABI.

* Include the below code in the `App.js` file:

  ```
  import { ethers } from "ethers";
  import Counter from "./contracts/Counter.sol/Counter.json";
  const counterAddress = "your-contract-address"
  console.log(counterAddress, "Counter ABI: ", Counter.abi);
  ```
* Update the `counterAddress` to your deployed address.
  * It is the hexadecimal number found at the tail-end of the output of the last `npx hardhat run ...` command and looks like this `0x5FbDB2315678afecb367f032d93F642f64180aa3`.
  * It must be pasted in the `App.js` to replace `your-contract-address`. Be sure to use the deployed address from your own implementation!
* Update frontend counter to read from blockchain. Include the below code in the `App.js` file:

  ```javascript
  useEffect(() => {
      // declare the data fetching function
      const fetchCount = async () => {
      const data = await readCounterValue();
      return data;
      };

      fetchCount().catch(console.error);
  }, []);

  async function readCounterValue() {
      if (typeof window.ethereum !== "undefined") {
          const provider = new ethers.providers.Web3Provider(window.ethereum);

          console.log("provider", provider);

          const contract = new ethers.Contract(
              counterAddress,
              Counter.abi,
              provider
          );

          console.log("contract", contract);

          try {
              const data = await contract.retrieve();
              console.log(data);
              console.log("data: ", parseInt(data.toString()));
              setCount(parseInt(data.toString()));
          } catch (err) {
              console.log("Error: ", err);
              alert(
                  "Switch your MetaMask network to Blast Chain and refresh this page!"
              );
          }
      }
  }
  ```
* Also, to import `useEffect`, insert it like this:

  ```javascript
  import { useState, useEffect } from "react";
  ```
* To be able to track a loader, add this to your state:

  ```javascript
  const [isLoading, setIsLoading] = useState(false);
  ```

  * This is within the `App()` function.
* Let frontend counter write to the blockchain by adding the below `requestAccount` and `updateCounter` functions:

  ```javascript
  async function requestAccount() {
  await window.ethereum.request({ method: "eth_requestAccounts" });
  }

  async function updateCounter() {
  if (typeof window.ethereum !== "undefined") {
      await requestAccount();
      const provider = new ethers.providers.Web3Provider(window.ethereum);
      console.log({ provider });
      const signer = provider.getSigner();
      const contract = new ethers.Contract(counterAddress, Counter.abi, signer);
      const transaction = await contract.increment();
      setIsLoading(true);
      await transaction.wait();
      setIsLoading(false);
      readCounterValue();
  }
  }
  ```

  Place these two functions above the `readCounterValue()` function in the `App.js` file.
* Replace the `incrementCounter` function with this one:

  ```javascript
  const incrementCounter = async () => {
  await updateCounter();
  };
  ```
* Update the increment button code to:

  ```javascript
  <Button
  onClick={incrementCounter}
  variant="outlined"
  disabled={isLoading}
  >
  {isLoading ? "loading..." : "+1"}
  </Button>
  ```

Now, run the Counter dApp by simply using `npm start` in CLI at the project root.

Congratulations for reaching this far. You have successfully deployed a dApp on the Blast Chain.


# Estimate gas fees

Estimating gas fees accurately is crucial for efficient transactions on the Blast Chain. You can use JSON-RPC API calls to retrieve the current gas price from the network. This tutorial will guide you through the process using a JSON-RPC request.

#### Using JSON-RPC to Estimate Gas Fees

You will need to send a JSON-RPC request to the Blast Chain's RPC endpoint to fetch the current gas price. Here’s how you can do it using `curl` from the command line:

```bash
bashCopycurl -X POST https://zkevmrpc.blastchain.org \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0", "method":"eth_gasPrice", "params":[], "id":1}'
```

This command sends a POST request to the Blast Chain's RPC server. It uses the `eth_gasPrice` method, which is standard in the JSON-RPC specification for Ethereum-based blockchains. The server should respond with the current gas price in wei.

#### Understanding the Response

The response you receive will be in JSON format and will look something like this:

```json
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x3b9aca00" // This is an example; actual value may vary
}
```

The `result` field contains the gas price in wei. To convert this into a more understandable format like gwei, you might use a conversion function in your preferred programming language.

#### Converting Wei to Gwei in JavaScript

If you're using JavaScript, you can convert the wei value to gwei using a simple function, assuming you're utilizing a library like `ethers.js` or `web3.js`:

**Using ethers.js:**

```javascript
const { ethers } = require("ethers");

// Connect to the provider (node)
const provider = new ethers.providers.JsonRpcProvider('https://zkevmrpc.blastchain.org');

// Fetch the current gas price
provider.getGasPrice().then((gasPrice) => {
    console.log(`Current gas price: ${ethers.utils.formatUnits(gasPrice, 'gwei')} gwei`);
});
```

**Using web3.js:**

```javascript
const Web3 = require('web3');

// Connect to the network node
const web3 = new Web3('https://zkevmrpc.blastchain.org');

// Get the current gas price from the network
web3.eth.getGasPrice().then((gasPrice) => {
    console.log('The current gas price is:', gasPrice);
});

```

#### Summary

Estimating gas fees using the RPC interface is a direct and reliable method to ensure that your transactions are executed efficiently on the Blast Chain. It allows you to dynamically adjust gas prices in your applications based on current network conditions.

This method ensures you are always equipped with the latest information for transaction processing on the Blast Chain, facilitating better resource management and planning in your blockchain interactions.


# Running a Blast Node

### Setup Production Blast Node on Blast Chain

The Blast Chain Mainnet is available for developers to launch smart contracts, execute transactions, and experiment. This document will guide you through launching your own production Blast Node, which is integral to the operation of the Blast Chain.

Developers can set up a production Blast Node directly on the Blast Chain Mainnet. This setup involves running the synchronizer and utilizing the JSON-RPC interface to interact with the network.

**Info**

* Sequencer and prover functionalities specific details are beyond the scope of this document and are assumed to be in continuous development and testing.
* Syncing the Blast Node can take between 1-2 days depending on network conditions and hardware specifications. Efforts are underway to implement snapshots to improve syncing times.

#### Prerequisites

This tutorial requires Docker and Docker Compose installations. Start by creating a directory for your Blast Node:

```bash
mkdir -p ~/blast-node
```

#### Minimum Hardware Requirements

**Caution:**

* Ensure that your CPU supports the AVX2 instruction set as it is necessary for certain node operations.
* 16GB RAM
* 4-core CPU
* Approximately 250/350GB of storage (requirement will grow over time)

#### Software Requirements

* A One World Chain node, set up to connect to the Layer 1 network.
* Blast Node for the Layer 2 network.
* A synchronizer responsible for syncing data between L1 and L2.
* A JSON RPC server to interface with the L2 network.

#### One World Chain Node Setup

Begin by setting up the One World Chain node, which is crucial for the operation of the L2 Blast Node. Detailed instructions for setting up a One World Chain node can be found at the [One World Chain documentation](https://docs.oneworldchain.org/general-1/how-to-run-network-nodes).

#### Blast Node Setup

Once the One World Chain node setup is complete, proceed with the Blast Node setup. This setup is straightforward but can be adjusted for high-demand scenarios.

**Set up your Blast Node:**

1. **Open your command line/terminal:** Set your network and directory variables:

   ```bash
   # Define the network ("mainnet")
   ZKEVM_NET=mainnet

   # Define installation path
   ZKEVM_DIR=./path_to_install

   # Define your config directory
   ZKEVM_CONFIG_DIR=./path_to_config
   ```
2. **Download and extract the node software:** You may need `unzip` installed before running this command:

   ```bash
   git clone https://github.com/BLASTchain/blast-node.git
   ```
3. **Copy the example environment file and modify it:**

   ```bash
   cp $ZKEVM_DIR/$ZKEVM_NET/example.env $ZKEVM_CONFIG_DIR/.env
   nano $ZKEVM_CONFIG_DIR/.env
   ```

   Edit the `.env` file to match your configurations, including the RPC URLs and data directories.
4. **To run the Blast Node instance, use the following Docker command:**

   ```bash
   sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml up -d
   ```
5. **Verify the setup:** Check the components are running correctly:

   ```bash
   docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml ps
   ```

#### Testing

To test your setup, query the most recently synchronized L2 block:

```bash
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545
```

#### Stopping the Blast Node

To stop your Blast Node:

```bash
sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml down
```

#### Troubleshooting

If there are port conflicts or container issues, adjust the necessary settings in the Docker compose file and review container logs for errors.

This revised setup provides a framework for running a Blast Node, facilitating effective Layer 2 scaling and interaction on your infrastructure with the Layer 1 support of the One World Chain.


