Mempool API
In this section we will look at some examples of how to write mempool queries to extract the necessary data from broadcasted transactions. To read more about how we offer mempool data, read the introduction here
Simulating Pending Transactions​
The below query retrieves information about in-flight transactions, helping you simulate the most recent state. It is a way to see if they will succeed without sending them on-chain. The Success
field tells you if your mempool tranaction is successful and FaultError
and FaultError
indicate otherwise.
You can find query here
subscription{
EVM(mempool: true) {
Transfers{
Log {
Index
}
Transaction {
Time
Type
To
Gas
From
Cost
Hash
}
Transfer {
Amount
Currency {
Name
}
Type
}
TransactionStatus {
Success
FaultError
FaultError
}
Block {
Time
}
}
}
}
Get Recommended Fees​
The Recommended Fees API provides real-time data from the mempool. It returns fields such as block time, block number, transaction hash, transaction cost, sender address, recipient address, base fee, burnt fees, sender fees, priority fees per gas, miner rewards, gas refunds, effective gas prices, and potential savings. You can use it to build applications that require up-to-date information about recommended transaction fees.
You can run the query here
{
EVM(mempool: true) {
Transactions(limit: {count: 100}) {
Block {
Time
Number
BaseFee
}
Transaction {
Hash
Cost
To
From
}
Fee {
Burnt
SenderFee
PriorityFeePerGas
MinerReward
GasRefund
EffectiveGasPrice
Savings
}
}
}
}