Flashblocks are a new development on the Base L2 that allow for faster transaction confirmation times, with most pre-confirmations happening under 200ms. Follow the guide below to learn how to use Flashblocks with Privy for lightning-fast transaction confirmations.

0. Set up Privy in your app

To start, if you haven’t yet set up Privy, follow the Privy React Quickstart to get your app instrumented with Privy’s basic functionality. After getting set up with the React SDK, install the @privy-io/chains package:
npm i @privy-io/chains

1. Get your Flashblocks RPC URL

Next, get a Flashblocks RPC URL that you can use to make RPC requests to the Base or Base Sepolia network. Base offers the following public RPCs:
  • Mainnet: https://mainnet-preconf.base.org
  • Sepolia: https://sepolia-preconf.base.org
We do not recommend using these endpoints in production as these are heavily rate-limited. Most Node providers like Quicknode, Alchemy, and Infura offer Flashblocks RPCs for Base.

2. Set a custom RPC URL for Base and/or Base Sepolia

Next, configure your chain representations for Base or Base Sepolia to use your Flashblocks RPC URL from step 1. To do so, use the addRpcUrlOverride method from @privy-io/chains to set your RPC URL in a viem chain object:
import {base, baseSepolia} from 'viem';
import {addRpcUrlOverride} from '@privy-io/chains';

const baseWithFlashblocks = addRpcUrlOverride(base, 'insert-flashblocks-rpc-url-for-base');
const baseSepoliaWithFlashblocks = addRpcUrlOverride(
  baseSepolia,
  'insert-flashblocks-rpc-url-for-base-sepolia'
);
Then, pass the chain representations with your custom Flashblocks RPC URLs to the PrivyProvider’s defaultChain and supportedChains property:
<PrivyProvider
    appId='your-privy-app-id'
    config={{
        ...theRestOfYourConfig,
        // Replace this with your desired default chain
        defaultChain: baseWithFlashblocks
        supportedChains: [baseWithFlashblocks, baseSepoliaWithFlashblocks, ...otherChains]
    }}
>
    {/* your app's content */}
</PrivyProvider>

3. Send transactions

That’s it! Privy will now route transactions on Base and/or Base Sepolia through the Flashblocks RPC URL you configured. Transactions should execute with <200ms pre-confirmation times.