payment_queryInfo - FLOP RPC Method
Estimate transaction fees on FLOP. Get the weight, dispatch class, and partial fee for an extrinsic before submitting it to the network.
FLOP RPC endpoint: endpoint URLs, plans and pricing.
Estimates the fee for an encoded extrinsic on FLOP. Returns the weight, dispatch class, and partial fee so you can display costs to users or verify sufficient balance before submitting transactions.
Why FLOP? Build on the Substrate Proof of Inference Layer 1 built for autonomous AI agents with Proof of Inference with TOPLOC activation commitments, full historical archive state from genesis, and JSON-RPC v2 archive and chainHead APIs.
When to Use This Method
payment_queryInfo is essential for AI agent builders, FLOP miners, indexers, and Substrate developers:
- Fee Display -- Show users the estimated transaction cost before they sign on FLOP
- Balance Validation -- Verify the sender has sufficient funds to cover the fee plus the transfer amount for Proof of Inference settlement, 1-second BABE blocks with AlephBFT finality, archive state queries, and HTLC atomic swaps
- Transaction Planning -- Compare fees across different extrinsic types to optimize costs
- Batch Cost Estimation -- Estimate the total cost of batch transactions before submission
Best Practices
- Fees may change before extrinsic inclusion due to network conditions
- The
partialFeeis returned in planck (smallest unit of the native token) - Test with actual encoded extrinsic data for the most accurate fee estimate
- Use
payment_queryFeeDetailsfor a component-level fee breakdown
{
"jsonrpc": "2.0",
"method": "payment_queryInfo",
"params": ["0x4d0284ff..."],
"id": 1
}Code Examples
Common Use Cases
1. Pre-Transaction Fee Display
Show fees to users before they confirm a transaction:
import { ApiPromise, WsProvider } from '@polkadot/api';
import { BN } from '@polkadot/util';
async function displayFeeEstimate(api, extrinsic, senderAddress) {
const [info, properties] = await Promise.all([
extrinsic.paymentInfo(senderAddress),
api.rpc.system.properties()
]);
const decimals = properties.tokenDecimals.toJSON()[0];
const symbol = properties.tokenSymbol.toJSON()[0];
const fee = info.partialFee;
// Convert to human-readable
const divisor = new BN(10).pow(new BN(decimals));
const whole = fee.div(divisor);
const fractional = fee.mod(divisor).toString().padStart(decimals, '0');
const formatted = `${whole}.${fractional.slice(0, 6)} ${symbol}`;
console.log(`Estimated fee: ${formatted}`);
console.log(`Dispatch class: ${info.class.toString()}`);
return { fee: fee.toString(), formatted, class: info.class.toString() };
}2. Sufficient Balance Check
Verify the sender can afford the transaction plus fees:
async function canAffordTransaction(api, senderAddress, recipient, amount) {
const transfer = api.tx.balances.transferKeepAlive(recipient, amount);
const [info, account] = await Promise.all([
transfer.paymentInfo(senderAddress),
api.query.system.account(senderAddress)
]);
const fee = info.partialFee.toBigInt();
const transferAmount = BigInt(amount);
const totalCost = fee + transferAmount;
const freeBalance = account.data.free.toBigInt();
// Account for existential deposit
const existentialDeposit = api.consts.balances.existentialDeposit.toBigInt();
const available = freeBalance - existentialDeposit;
const canAfford = available >= totalCost;
console.log(`Free balance: ${freeBalance}`);
console.log(`Total cost (amount + fee): ${totalCost}`);
console.log(`Can afford: ${canAfford}`);
return canAfford;
}3. Compare Fees Across Transaction Types
Estimate fees for different operations to find the cheapest approach:
async function compareFees(api, sender) {
const recipient = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const amount = 1000000000000;
// Different transaction types
const extrinsics = {
'transfer': api.tx.balances.transferKeepAlive(recipient, amount),
'transferAll': api.tx.balances.transferAll(recipient, false),
'batchTransfer': api.tx.utility.batchAll([
api.tx.balances.transferKeepAlive(recipient, amount / 2),
api.tx.balances.transferKeepAlive(recipient, amount / 2)
])
};
const fees = {};
for (const [name, ext] of Object.entries(extrinsics)) {
const info = await ext.paymentInfo(sender);
fees[name] = {
partialFee: info.partialFee.toHuman(),
weight: info.weight.toString(),
class: info.class.toString()
};
}
console.table(fees);
return fees;
}Error Handling
Common errors and solutions:
| Error Code | Description | Solution |
|---|---|---|
| -32603 | Unable to query dispatch info | Ensure the extrinsic is properly encoded; verify it is a valid call for the current runtime |
| -32602 | Invalid params | Check the extrinsic hex is properly formatted with 0x prefix |
| -32005 | Rate limit exceeded | Implement client-side rate limiting or cache fee estimates for similar transactions |
| Execution error | Runtime unable to compute fee | The extrinsic may reference invalid pallets or calls; verify against current metadata |
Related Methods
author_submitExtrinsic-- Submit the extrinsic after verifying the feepayment_queryFeeDetails-- Get a detailed fee breakdown (base fee, length fee, weight fee)system_properties-- Get token decimals and symbol for formatting the feestate_call-- CallTransactionPaymentApidirectly for advanced fee queriesauthor_pendingExtrinsics-- Check pending extrinsics in the pool
author_submitAndWatchExtrinsic
Submit an extrinsic and subscribe to lifecycle status updates on FLOP. Track transactions from pool admission through finalization with real-time WebSocket events for Proof of Inference settlement, 1-second BABE blocks with AlephBFT finality, archive state queries, and HTLC atomic swaps.
payment_queryFeeDetails
Get a detailed fee breakdown for an extrinsic on FLOP. Analyze base fee, length fee, and adjusted weight fee components to optimize transaction costs for Proof of Inference settlement, 1-second BABE blocks with AlephBFT finality, archive state queries, and HTLC atomic swaps.