跳至主要內容

Measure Ethereum Transaction Latency in Real-Time with txping

更新於
2026年6月1日

閱讀時間 3 分鐘

概覽

When fine-tuning a trading bot, benchmarking a client, or investigating slow transaction propagation, it is critical to obtain accurate latency metrics.

txping is a lightweight Node.js utility that simplifies this process. It sends a signed 0 ETH transaction through your Quicknode RPC endpoint and reports:


  • RPC latency — measured as the time between transaction submission and hash acknowledgment.
  • Block inclusion latency — measured as the time between transaction submission and its first confirmation.

By repeating this process, you can establish a baseline for transaction propagation performance across Ethereum Mainnet.


您將負責的工作內容

在本指南中,您將:


  • Configure and run txping locally.
  • Generate a dedicated test wallet and fund it.
  • Benchmark your Ethereum RPC endpoint and record latency metrics.
  • Adjust transaction fees to optimize results under real-world conditions.

您需要準備的物品

RequirementVersion / Notes
Node.js≥ 20.x
NPM≥ 10.x
Quicknode RPC URLEthereum Mainnet endpoint
FundsA small amount of ETH (~0.01)
FamiliarityBasic CLI and Ethereum concepts

Why Latency Matters

Transaction latency is a key metric for a broad range of Ethereum use cases:


  • Trading bots and arbitrage require near-instant transaction propagation to capitalize on price movements.
  • NFT minting often demands transactions to confirm within seconds to secure a limited drop.
  • User-facing dApps depend on quick transaction finality to maintain a smooth user experience.
  • DeFi protocols require timely settlement to minimize slippage and maximize yield.

In practice, transaction latency varies due to network congestion and gas pricing dynamics. When the Ethereum network is busy, transactions with insufficient gas fees may wait in the mempool for extended periods before confirmation.
By benchmarking your endpoint under different gas and network conditions, you can proactively optimize fees and improve application performance.


Project Setup

  1. Clone the repository:

    git clone https://github.com/lvandeyar/txping.git
    cd txping
    npm install
  2. Create a new test wallet:

    node create-wallet.js

    Save the printed address and private key.

  3. Create an .env file and configure the following environment variables:

    QUICKNODE_RPC_URL=https://your-endpoint.quiknode.pro/...
    PRIVATE_KEY=0xYOUR_PRIVATE_KEY
    WALLET_ADDRESS=0xYOUR_ADDRESS
  4. Fund the wallet with a small amount of ETH on Ethereum Mainnet.


Running the Benchmark

Run the script to send and measure transaction timings:

npm start

You will see output similar to:

➤ RPC latency: 94 ms
➤ Inclusion time: 12.6 s
➤ Included in block: 20456789

Repeat the test multiple times to establish average and percentile latencies.


Implementation Details

The core logic is straightforward:

const rpcStart = Date.now();
const txResponse = await provider.sendTransaction(signedTx);
const rpcLatency = Date.now() - rpcStart;

const inclusionStart = Date.now();
const receipt = await txResponse.wait();
const inclusionTime = (Date.now() - inclusionStart) / 1000;

console.log(`➤ RPC latency: ${rpcLatency} ms`);
console.log(`➤ Inclusion time: ${inclusionTime.toFixed(1)} s`);

This structure allows you to integrate the utility into your existing workflow or CI/CD pipeline.


Considerations for Gas Pricing

txping uses EIP-1559 style transactions with sensible defaults:


  • Gas limit: 21 000
  • Priority fee per gas: 1 gwei

You can adjust these parameters as needed. Increasing the priority fee may improve inclusion times during periods of congestion.


安全性與最佳實務


  • Do not use this wallet for anything other than testing.
  • Do not commit the .env file containing your private key.
  • Consider isolating your tests to a dedicated Quicknode project for logging and metrics purposes.

下一步

This version of txping is intended for Ethereum Mainnet.

If you would like to use this utility on other EVM chains (e.g. Polygon, BNB Chain, Avalanche C-Chain), please contact the Quicknode team to help adapt this utility for additional networks or to request enhancements.


總結

With minimal setup and less than 100 lines of code, txping allows you to benchmark RPC latency and transaction inclusion time for Ethereum Mainnet.

By generating a baseline for your setup, you can proactively monitor your transaction performance, identify bottlenecks, and ensure your application meets its target service level objectives.

If you have any questions or need help with your Solana development projects, join us in the Quicknode Discord or follow us on Twitter.

我們 ❤️ 您的回饋!

Let us know if you have any feedback or requests for new topics. We'd love to hear from you.

分享這份指南