payment_queryFeeDetails
Returns a detailed breakdown of fees for a given extrinsic on Bridge Hub. Unlike payment_queryInfo which returns the total fee, this method separates the fee into its component parts.
Use Cases#
- Fee analysis - Understand fee composition for trustless ETH and ERC-20 bridging, cross-chain messaging, and parachain-to-Ethereum asset transfers
- Optimization - Identify which fee component dominates costs
- Debugging - Diagnose unexpected fee amounts
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
extrinsic | Bytes | Yes | SCALE-encoded extrinsic (signed or unsigned) |
blockHash | Hash | No | Block hash for fee calculation context |
Returns#
| Field | Type | Description |
|---|---|---|
inclusionFee | Option<InclusionFee> | Fee details (null for unsigned extrinsics) |
InclusionFee Structure#
| Field | Type | Description |
|---|---|---|
baseFee | Balance | Fixed base fee per extrinsic |
lenFee | Balance | Fee based on encoded extrinsic length |
adjustedWeightFee | Balance | Fee based on execution weight |
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-bridge-hub-polkadot.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "payment_queryFeeDetails",
"params": ["0x...encodedExtrinsic"],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-bridge-hub-polkadot.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
// Create a sample transfer
const tx = api.tx.balances.transferKeepAlive(
'5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
1000000000000n
);
// Get fee details
const feeDetails = await api.rpc.payment.queryFeeDetails(tx.toHex());
if (feeDetails.inclusionFee.isSome) {
const fee = feeDetails.inclusionFee.unwrap();
console.log('Base fee:', fee.baseFee.toString());
console.log('Length fee:', fee.lenFee.toString());
console.log('Weight fee:', fee.adjustedWeightFee.toString());
}
await api.disconnect();
import requests
url = 'https://api-bridge-hub-polkadot.n.dwellir.com/YOUR_API_KEY'
# Replace with actual encoded extrinsic
encoded_extrinsic = '0x...'
payload = {
'jsonrpc': '2.0',
'method': 'payment_queryFeeDetails',
'params': [encoded_extrinsic],
'id': 1
}
response = requests.post(url, json=payload)
result = response.json()['result']
if result['inclusionFee']:
fee = result['inclusionFee']
print(f"Base fee: {fee['baseFee']}")
print(f"Length fee: {fee['lenFee']}")
print(f"Weight fee: {fee['adjustedWeightFee']}")
Fee Components Explained#
| Component | Calculation | Optimization |
|---|---|---|
| Base fee | Fixed per extrinsic | Batch calls to share base fee |
| Length fee | length * lengthToFee | Minimize call data size |
| Weight fee | weight * weightToFee | Choose efficient operations |
Related Methods#
payment_queryInfo- Get total fee estimateauthor_submitExtrinsic- Submit transactionstate_call- Call TransactionPaymentApi directly