How to Build Crypto Trading Bot Infrastructure with RPC Nodes

blog_author_logo
GETBLOCK

June 1, 2026

9 min read

How to Build Crypto Trading Bot Infrastructure with RPC Nodes

Trading bots are the most demanding RPC consumers in crypto. A simple price monitor might make 100,000 calls per day, which is manageable. An arbitrage bot needs sub-10ms latency to be profitable, which is harder to achieve. An MEV searcher needs private transaction submission to avoid getting sandwiched by the very bots it's competing against, which requires a fundamentally different infrastructure setup.

What makes trading bot infrastructure uniquely challenging is that the stakes scale directly with latency. A wallet that's 50ms slower shows a balance a moment later — no one loses money. A trading bot that's 50ms slower misses the arbitrage opportunity entirely, or worse, executes the trade at a worse price than intended. Every architectural decision in this guide is driven by that reality.

Two Jobs: Reading State and Writing Transactions

Every trading bot, regardless of strategy, needs two capabilities from its RPC infrastructure:

  1. Reading blockchain state (prices, balances, pool reserves, order book positions)

  2. Writing transactions (submitting swaps, limit orders, liquidations). 

What varies is how fast and how often each operation needs to happen.

  • A price-monitoring bot reads pool reserves every few seconds and never writes any transactions. The latency requirement is relaxed; a 100ms round-trip is perfectly fine.

  • An arbitrage bot reads reserves on every new block and writes a swap transaction when it finds a profitable spread. It needs both reads and writes to complete in under 50ms to be competitive.

  • A liquidation bot continuously monitors health metrics across lending protocols and executes liquidation calls when positions become underwater. It needs sub-20ms latency because it's racing other liquidators for the same opportunity.

And at the extreme end, token snipers subscribe to pending transactions in the mempool and need to react within 10ms; the speed at which the entire read-evaluate-execute loop completes determines whether the trade lands.

Ready to start building? Get your free API key and connect your trading bot to production-grade infrastructure.

Architecture Pattern 1: Simple Bots on Shared Infrastructure

For price monitors, portfolio trackers, and low-frequency strategies, shared RPC endpoints are the right starting point. The architecture is minimal:

  1. Your bot connects to a shared GetBlock endpoint

  2. Reads data, and either logs it or makes occasional trading decisions.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

from web3 import Web3
import time
import json
w3 = Web3(Web3.HTTPProvider("https://go.getblock.io/<YOUR_ACCESS_TOKEN>/"))
# Monitor DEX pool reserves on a simple polling loop
POOL_ADDRESS = "0x..."  # Uniswap V2 pair
RESERVES_ABI = '{"inputs":[],"name":"getReserves","outputs":[{"type":"uint112"},{"type":"uint112"},{"type":"uint32"}],"type":"function"}'
pool = w3.eth.contract(
    address=POOL_ADDRESS, abi=[json.loads(RESERVES_ABI)]
)

while True:
    reserves = pool.functions.getReserves().call()
    price = reserves[0] / reserves[1]
    print(f"Price: {price:.6f}")
    time.sleep(10)

This is a perfectly valid production setup for monitoring. GetBlock's free tier (50,000 CU per day) handles a bot like this comfortably, and the Starter plan at $49/month covers more active polling strategies. The key limitation is latency. A shared endpoint averages around 10ms, which is fine for monitoring but not competitive for execution-sensitive strategies.

Architecture Pattern 2: Performance Bots with Dedicated Nodes

Arbitrage bots, liquidation bots, and medium-frequency strategies need a different infrastructure tier. The architecture separates concerns: a dedicated HTTP endpoint for low-latency state reads, a WebSocket connection for real-time block and event subscriptions, and a dedicated path for transaction submission.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

import { WebSocketProvider, JsonRpcProvider, Wallet } from "ethers";
const httpProvider = new JsonRpcProvider(
  "https://go.getblock.io/<DEDICATED_TOKEN>/"
):
const wsProvider = new WebSocketProvider(
  "wss://go.getblock.io/<DEDICATED_TOKEN>/"
);
wsProvider.on("block", async (blockNumber) => {
  const reserves = await pool.getReserves({
    blockTag: blockNumber,
  });
  const profit = calculateArbitrage(reserves);
  if (profit > MIN_PROFIT_THRESHOLD) {
    const tx = await wallet.sendTransaction(buildSwapTx(reserves));
    console.log(
      `Arbitrage executed: ${tx.hash}, expected profit: ${profit}`
);

  }
});

The WebSocket subscription is critical here. Without it, you'd poll for new blocks on a timer, and even polling every second means you're sometimes reacting to a block nearly a full second after it was produced. 

With WebSocket, you receive block notifications the moment they're available, which can be the difference between capturing and missing an arbitrage spread.

Dedicated nodes on GetBlock average approximately 4ms latency compared to around 10ms on shared endpoints. That difference compounds when your bot makes multiple sequential reads per block, so a three-call evaluation loop takes 12ms on dedicated and 30ms on shared.

Architecture Pattern 3: HFT and MEV Infrastructure

At the highest performance tier, trading infrastructure on Solana and BSC requires specialized tools beyond standard RPC.

On Solana, GetBlock's TradeFirst suite provides two advantages that standard RPC can't match. StreamFirst uses Yellowstone gRPC to deliver account state updates faster than any polling or WebSocket approach, approximately 17ms ahead of standard RPC. This means your bot sees pool state changes before competitors using conventional endpoints. LandFirst combines SWQoS routing with Jito bundles to maximize the probability that your transaction actually lands on-chain, the other half of the equation. Seeing the opportunity first means nothing if your transaction gets dropped.

On BSC, the challenge is different: front-running. When you submit a swap through the public mempool, MEV bots can see your transaction and sandwich it by buying before your swap to drive the price up, then selling after to extract value. GetBlock's BSC Accelerated Dedicated Node includes private mempool access via the BDN, which means your transaction is submitted directly to block producers without appearing in the public mempool.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

import requests
# Transaction submitted via private mempool — invisible to sandwich bots
tx_hex = "0x..."  # Your signed transaction
response = requests.post(
    "https://go.getblock.io/<BSC_DEDICATED_TOKEN>/",
    headers={"Content-Type": "application/json"},
    json={
        "jsonrpc": "2.0",
        "method": "eth_sendRawTransaction",
        "params": [tx_hex],
        "id": 1,
    },
)
print(f"TX Hash: {response.json()['result']}")

On Ethereum, private mempool setups (Flashbots-style) are available through custom configurations — contact GetBlock's team for enterprise setups.

Latency Optimization: Five Rules

Trading bot performance lives and dies on latency. Here are the five optimizations that matter most, in order of impact.

1. Choose the right region:

GetBlock operates in Frankfurt, New York, and Singapore. Frankfurt is the best choice for Solana bots because it has the highest validator stake density. Co-locate your bot server in the same region as your RPC endpoint; adding a cross-continental round trip negates every other optimization.

2. Use WebSocket subscriptions instead of polling:

Every polling interval is dead time where your bot isn't reacting to new data. WebSocket delivers events as soon as they're available.

1

2

3

4

5

6

7

8

// Polling: wastes CU, adds up to 1 second of unnecessary latency
setInterval(async () => {
  const block = await provider.getBlockNumber();
}, 1000);
// WebSocket: instant notification, zero wasted time
wsProvider.on("block", (blockNumber) => {
  // React immediately
});

3. Batch your RPC calls:

If your evaluation logic requires multiple data points, fetch them in parallel rather than sequentially.

1

2

3

4

5

6

7

8

9

10

// Sequential: 3x the latency (12ms becomes 36ms)
const balance1 = await provider.getBalance(addr1);
const balance2 = await provider.getBalance(addr2);
const gasPrice = await provider.getFeeData();
// Parallel: 1x the latency (12ms stays 12ms)
const [balance1, balance2, gasPrice] = await Promise.all([
  provider.getBalance(addr1),
  provider.getBalance(addr2),
  provider.getFeeData(),
]);

4. Separate your read and write paths:

Reads and writes have different performance characteristics and different failure modes. Using separate endpoints lets you optimize each independently and prevents a write failure from blocking your reads.

1

2

3

4

5

6

const readProvider = new JsonRpcProvider(
  "https://go.getblock.io/<DEDICATED_READ>/"
);
const writeProvider = new JsonRpcProvider(
  "https://go.getblock.io/<DEDICATED_WRITE>/"
);

5. Optimize gas estimation:

Use eth_estimateGas and eth_maxPriorityFeePerGas on EVM chains to avoid overpaying — overpaying gas directly reduces your trading profit. On Solana, use getRecentPrioritizationFees to set competitive but not excessive priority fees.

Common Mistakes That Cost Real Money

These errors are specific to trading bots, and each one translates directly into lost profit or increased risk.

1. Using public free RPCs for production trading:

Public endpoints throttle aggressively under load. Your bot will miss opportunities during exactly the moments they matter most, high-volatility periods when everyone is hitting the same endpoints.

2. Not handling rate limit errors:

When you hit a 429 response, your bot needs to back off intelligently, not crash or spin in a tight retry loop. Exponential backoff is the standard pattern:

1

2

3

4

5

6

7

8

9

10

11

12

import time
import requests

def rpc_call_with_retry(payload, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(RPC_URL, json=payload)
        if response.status_code == 429:
            time.sleep(2 ** attempt)  # 1s, 2s, 4s
            continue
        return response.json()
    raise Exception("Rate limited after retries")

3. Running without a failover endpoint:

A single-endpoint bot is a single point of failure. If your RPC endpoint has even a brief hiccup during a volatile market, your bot goes blind. Always configure a fallback:

1

2

3

4

5

6

const primary = new JsonRpcProvider(
  "https://go.getblock.io/<TOKEN_1>/"
);
const fallback = new JsonRpcProvider(
  "https://go.getblock.io/<TOKEN_2>/"
);

4. Polling when you should be subscribing:

Every unnecessary poll is wasted CU and adds latency. If your data source supports WebSocket or gRPC streaming, use it. The difference between polling at 1-second intervals and receiving WebSocket events is the difference between sometimes profitable and consistently profitable.

Putting It Together: A DEX Arbitrage Bot

Here's a minimal but complete architecture for a cross-DEX arbitrage bot on Ethereum. It monitors price differences between Uniswap and SushiSwap and executes when the spread exceeds a threshold:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

from web3 import Web3
import asyncio
# Dedicated node for consistent low-latency performance
w3 = Web3(Web3.HTTPProvider(
    "https://go.getblock.io/<DEDICATED_TOKEN>/"
))
UNISWAP_POOL = "0x..."
SUSHISWAP_POOL = "0x..."
async def check_arbitrage():
    """Check price difference between two DEXes."""
    # Read both pool reserves (ideally in parallel)
    uni_reserves = uniswap_pool.functions.getReserves().call()
    sushi_reserves = sushiswap_pool.functions.getReserves().call()
    uni_price = uni_reserves[0] / uni_reserves[1]
    sushi_price = sushi_reserves[0] / sushi_reserves[1]
    spread = abs(uni_price - sushi_price) / min(
        uni_price, sushi_price
    )

    if spread > 0.003:  # > 0.3% spread
        return True
    return False
async def main():
    while True:
        await check_arbitrage()
        await asyncio.sleep(1)
asyncio.run(main())

In production, you'd replace the polling loop with a WebSocket block subscription, add the failover pattern, and batch the two reserve reads into a single Promise.all equivalent, and submit trades through a private mempool endpoint. But the core logic — read, compare, execute — stays the same at every scale.

Conclusion

Trading bot infrastructure is fundamentally about latency management and reliability. The strategies vary enormously — from a simple price monitor on a 10-second polling loop to a Solana MEV searcher processing gRPC account streams in single-digit milliseconds — but the infrastructure concerns are consistent: minimize the time between data arriving and your bot reacting, ensure your transaction submission path is fast and protected from front-running, and always have a fallback for when things go wrong.

GetBlock's infrastructure spans the full range — shared endpoints for development and low-frequency strategies, dedicated nodes with approximately 4ms latency for competitive execution, and specialized tooling like StreamFirst, LandFirst, and BSC private mempool access for high-frequency and MEV-sensitive operations.

Ready to start building? Get your free API key and connect your trading bot to production-grade infrastructure.

blog_author_logo
GETBLOCK

June 1, 2026

9 min read

twittertwittertelegramtelegramLinkedinLinkedin