# payment_queryFeeDetails - Centrifuge RPC Method

Returns a detailed breakdown of fees for a given extrinsic on Centrifuge. 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 tokenized treasury funds, SME invoice financing, and institutional-grade RWA infrastructure
- **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

```bash
curl https://api-centrifuge.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
  }'
```

```javascript
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-centrifuge.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();
```

```python
import requests

url = 'https://api-centrifuge.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`](https://www.dwellir.com/docs/centrifuge/payment_queryInfo) - Get total fee estimate
- [`author_submitExtrinsic`](https://www.dwellir.com/docs/centrifuge/author_submitExtrinsic) - Submit transaction
- [`state_call`](https://www.dwellir.com/docs/centrifuge/state_call) - Call TransactionPaymentApi directly
