3 min read
Overview
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.
What You Will Do
In this guide, you will:
- 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.
What You Will Need
Requirement | Version / Notes |
---|---|
Node.js | ≥ 20.x |
NPM | ≥ 10.x |
QuickNode RPC URL | Ethereum Mainnet endpoint |
Funds | A small amount of ETH (~0.01) |
Familiarity | Basic 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
-
Clone the repository:
git clone https://github.com/lvandeyar/txping.git
cd txping
npm install -
Create a new test wallet:
node create-wallet.js
Save the printed address and private key.
-
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 -
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.
Security and Best Practices
- 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.
Next Steps
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.
Wrap Up
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.
We ❤️ Feedback!
Let us know if you have any feedback or requests for new topics. We'd love to hear from you.