跳转到主要内容

参数

addresses
array
账户地址数组(base-58 编码的字符串)。如果提供,响应将仅包含由这些地址之一支付的优先费。

响应

result
array

代码示例

基本请求

curl http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getRecentPrioritizationFees",
  "params": [
    ["CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"]
  ]
}'

使用 web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const address = 'CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY';
const fees = await connection.getRecentPrioritizationFees([address]);
console.log(fees);

使用 Python

from solana.rpc.api import Client

client = Client("http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY")
address = "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"
response = client.get_recent_prioritization_fees([address])
print(response)

注意事项

  1. 返回区块中的近期优先费列表
  2. 对于估算优先交易的费用非常有用
  3. 费用以 micro-lamports 报告(LAMPORTS_PER_SOL/1000000)
  4. 如果提供了 addresses 参数,结果将过滤为这些账户
  5. 响应可用于计算适当的优先费

最佳实践

  1. 在网络拥堵时使用此方法确定适当的优先费
  2. 如果只关心特定账户支付的费用,按特定地址过滤
  3. 根据近期费用的平均值或百分位数计算适当的费用
  4. 在网络活动频繁时频繁刷新费用数据
  5. 适当处理网络错误并重试