Skip to content

Node provider docs for flashblocks #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Flashblocks
slug: /flashblocks
slug: /flashblocks/apps
description: Experience lightning-fast transaction confirmations on Base by using Flashblocks. Preconfirmations happen in just 200 milliseconds—designed for real-time apps, games, and seamless UX.
---

Expand All @@ -14,9 +14,129 @@ Flashblocks enable up to 200 millisecond transaction confirmations on Base by le

Flashblocks is enabled for developers on Base Sepolia with full support for mainnet coming very soon. There are two ways you can integrate with Flashblocks data. You can either use the WebSocket API to stream real-time block updates, or use the RPC API to query the Flashblocks-aware RPC endpoint.

### RPC API
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think app devs use RPC more so I moved it to the top


You can utilize our Flashblock aware RPC endpoint at `https://sepolia-preconf.base.org`.

In addition to these flashblock-specific methods, all standard Ethereum JSON-RPC methods are supported as usual.

#### eth_getBlockByNumber

Use the `pending` tag to retrieve the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["pending",true],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"number": "0x1234",
"hash": "0x...",
"transactions": [...]
}
}
```

#### eth_getTransactionReceipt

Use the existing receipt RPC to get preconfirmed receipts:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x..."],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"transactionHash": "0x...",
"blockNumber": "0x1234",
"status": "0x1"
}
}
```

#### eth_getBalance

Use the `pending` tag to get the address balance in the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x...","pending"],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0234"
}
```

#### eth_getTransactionCount

Use the `pending` tag to get the address nonce in the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x...","pending"],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1b" // 27 transactions
}
```

### Libraries

For popular libraries, they sometimes require additional RPC support for transaction preconfirmation to work properly.
We are working on adding Flashblocks support to the following libraries:

#### [Ethers](https://github.com/ethers-io/ethers.js) (Completed 🟢)

```
const providerA = new ethers.JsonRpcProvider(
"https://sepolia-preconf.base.org"
);

const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, providerA);

try {
// Create a simple transaction (sending 0.001 ETH to a random address)
const tx = {
to: "<SOME ADDRESS>",
value: ethers.parseEther("0.0000001"),
};

// Submit transaction
const submissionTime = new Date();
const transaction = await wallet.sendTransaction(tx);

console.log(`Submitting transaction at: ${submissionTime.toISOString()}`);
console.log(`Transaction hash: ${transaction.hash}`);

await transaction.wait(0); // Make sure to set the confirmation count to 0

console.log("Transaction confirmed");
const confirmationTime = new Date();
console.log(`Transaction confirmed at: ${confirmationTime.toISOString()}`);
console.log(`Time difference: ${confirmationTime - submissionTime}ms`);
}
```
You should see the confirmation time significantly lower than the standard RPC endpoint.

#### Viem (Coming soon 🟡)

#### Wagmi (Coming soon 🟡)

### WebSocket API

Use our API to stream realtime block updates over a WebSocket.
You can also use our WebSocket API to stream realtime flashblocks updates.

You can connect to the websocket endpoint with any WebSocket library of CLI tool. The endpoint is available at wss://sepolia.flashblocks.base.org/ws.

Expand Down Expand Up @@ -114,83 +234,7 @@ To minimize the amount of data sent to clients, each Flashblock only includes th
}
```

### RPC API

You can also utilize our Flashblock aware RPC endpoint at `https://sepolia-preconf.base.org`.

In addition to these flashblock-specific methods, all standard Ethereum JSON-RPC methods are supported as usual.

#### eth_getBlockByNumber

Use the `pending` tag to retrieve the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["pending",true],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"number": "0x1234",
"hash": "0x...",
"transactions": [...]
}
}
```

#### eth_getTransactionReceipt

Use the existing receipt RPC to get preconfirmed receipts:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x..."],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"transactionHash": "0x...",
"blockNumber": "0x1234",
"status": "0x1"
}
}
```

#### eth_getBalance

Use the `pending` tag to get the address balance in the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x...","pending"],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0234"
}
```

#### eth_getTransactionCount

Use the `pending` tag to get the address nonce in the latest Flashblock:
```
curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x...","pending"],"id":1}'
```

**Example Response**
```
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1b" // 27 transactions
}
```

## Support

Expand Down
51 changes: 51 additions & 0 deletions apps/base-docs/docs/pages/chain/flashblocks/node-providers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Flashblocks
slug: /flashblocks/node-providers
description: Experience lightning-fast transaction confirmations on Base by using Flashblocks. Preconfirmations happen in just 200 milliseconds—designed for real-time apps, games, and seamless UX.
---

# How to host Flashblocks-aware RPC nodes

## Quick Start

1. **Prerequisites**:

- Docker and Docker Compose
- Minimum hardware requirements (see [node README](https://github.com/base/node?tab=readme-ov-file#hardware-requirements))
- Access to a Flashblocks websocket endpoint, we provide public endpoints in the env files in the repo

2. **Set Up Environment**:

```bash
# Clone the repository
git clone https://github.com/base/node.git
cd node
```

3. **Start the Node with Flashblocks Support**:
```bash
NODE_TYPE=base CLIENT=reth docker-compose up
```

## Configuration Options

- **Node Type**: Use `NODE_TYPE=base` to enable base reth node withFlashblocks functionality
- **Network**: Use `NETWORK_ENV=.env.mainnet` for mainnet or `NETWORK_ENV=.env.sepolia` for testnet

## Verifying Flashblocks Functionality

Test that your node is properly supporting Flashblocks by querying a pending block:

```bash
curl -X POST \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["pending", false],"id":1}' \
http://localhost:8545
```

## Available RPC Methods

Flashblocks-aware nodes provide all standard Ethereum JSON-RPC methods plus specialized Flashblocks endpoints. For more details, see the [Flashblocks RPC API documentation](https://docs.base.org/chain/flashblocks/apps#rpc-api).

## Further Resources

For detailed information about node setup, including hardware requirements and additional configuration options, refer to the [Reth node README](https://github.com/base/op-geth/blob/main/node/reth/README.md).
4 changes: 4 additions & 0 deletions apps/base-docs/docs/public/serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
{
"source": "/identity/smart-wallet/guides/sub-accounts/incorporate-spend-permissions",
"destination": "/identity/smart-wallet/guides/sub-accounts/"
},
{
"source": "/chain/flashblocks",
"destination": "/chain/flashblocks/apps"
}
]
}
12 changes: 8 additions & 4 deletions apps/base-docs/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,6 @@ export const sidebar: Sidebar = [
text: 'Base Contracts',
link: '/chain/base-contracts',
},
{
text: 'Flashblocks',
link: '/chain/flashblocks',
},
{
text: 'Security Council',
link: '/chain/security-council',
Expand All @@ -1071,6 +1067,14 @@ export const sidebar: Sidebar = [
text: 'Chain Stats ↗',
link: 'https://www.base.org/stats',
},
{
text: 'Flashblocks',
collapsed: true,
items: [
{ text: 'Apps', link: '/chain/flashblocks/apps' },
{ text: 'Node Providers', link: '/chain/flashblocks/node-providers' },
],
},
],
},
{
Expand Down