Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Gas 定价参考

Stable 上的交易构建、gas 估算和工具链配置。

交易构建

在 Stable 上构建交易时,将 maxPriorityFeePerGas 设置为 0。客户端应从最新区块获取最新的 base fee,并在计算 maxFeePerGas 时加入安全余量。

// ethers.js v6
const block = await provider.getBlock("latest");
const baseFee = block.baseFeePerGas;
 
const maxPriorityFeePerGas = 0n; // always 0 on Stable
const maxFeePerGas = baseFee * 2n + maxPriorityFeePerGas; // double the base fee as safety margin
 
const tx = await wallet.sendTransaction({
  to: "0xRecipientAddress",
  value: parseEther("0.01"),
  maxFeePerGas,
  maxPriorityFeePerGas,
});
Native USDT0 transfer confirmed. Fee ≈ 0.0000021 USDT0 at baseFee = 1 gwei.

Gas 估算

像在 Ethereum 上一样使用 eth_estimateGaseth_gasPrice。关键区别在于 eth_maxPriorityFeePerGas 将始终返回 0

const gasPrice = await provider.send("eth_gasPrice", []);
const gasEstimate = await provider.estimateGas({
  to: contractAddress,
  data: callData,
});
 
const estimatedFeeInUSDT0 = gasPrice * gasEstimate;

工具链配置

  • Hardhat / Foundry:无需特殊配置;标准的 EVM 设置即可工作。如果你的配置显式设置了 priority fee,请将其设置为 0
  • 钱包:隐藏或禁用 priority tip 输入字段。显示它可能会让用户困惑,因为该值不起作用。
  • 监控:费用分析仪表板不应跟踪 priority fee。它们将始终为零。

推荐后续阅读