Pending transactions
onMempoolTransaction() calls you for every pending transaction seen on a network, the moment it appears — the whole mempool, not just one address. To follow the pending transactions of a single address, use onPendingTransaction().
const btc = cg.explore(cg.networks.bitcoin)
btc.onMempoolTransaction(({ txid, vsize, feeRate }) => {
console.log(`${txid} — ${vsize} vB at ${feeRate ?? '?'} sat/vB`)
})
High volume
Busy networks produce several pending transactions per second. Keep the callback light, and prefer the address-scoped events whenever you only care about a few addresses.
Pending events may be unavailable on some networks
Pending tracking is an optional capability of each network. Subscribing where it is not available succeeds, but no events arrive.
UTXO networks
| Field | Type | Description |
|---|---|---|
txid | string | Transaction id |
seenAt | number | Unix seconds when the transaction was first seen |
vsize | number | Virtual size, in vbytes |
fee | Amount | null | Fee paid; null when an input could not be resolved |
feeRate | number | null | Fee rate in satoshis per vbyte; null when the fee is unknown |
inputs[] | { prevTxid, prevN, prevAmount? } | The outputs being spent; prevAmount is present when it could be resolved |
outputs[] | { n, amount } | The outputs created |
EVM networks
Pending events cover the native coin only — gas is not included, and token transfers are not visible until the transaction is mined.
| Field | Type | Description |
|---|---|---|
hash | string | Transaction hash |
from | string | Sender |
to | string | null | Recipient; null for a contract creation |
value | Amount | Native value moved |
nonce | number | Sender nonce |
input | string | Calldata — "0x" for a plain transfer |
gas | bigint | Gas limit |
gasPrice | bigint | null | Legacy gas price in wei, when present |
maxFeePerGas | bigint | null | EIP-1559 max fee per gas in wei, when present |
maxPriorityFeePerGas | bigint | null | EIP-1559 priority fee per gas in wei, when present |
type | number | null | Transaction type (0 legacy, 1 EIP-2930, 2 EIP-1559), when reported |
chainId | number | null | Chain id, when reported |
seenAt | number | Unix seconds when the transaction was first seen |
const eth = cg.explore(cg.networks.ethereum)
eth.onMempoolTransaction(({ hash, value, maxFeePerGas }) => {
if (value.min() >= 100n * 10n ** 18n) {
console.log('Whale alert:', hash, value.base(), 'ETH', 'max fee', maxFeePerGas, 'wei')
}
})