For the complete documentation index, see llms.txt. This page is also available as Markdown.

免 Gas 交易(GasPool)

从中央资金池为代理钱包代付 Gas

如果您在运行机器人或程序化策略,无需为每个代理钱包充值 SUI 作为 Gas。您可以使用 GasPool,从一个预付余额为代理钱包的交易代付 Gas。

可以把 GasPool 理解为一张预付 Gas 卡。您从主钱包向其中充入 SUI(或 USDC),此后代理钱包每次执行交易,协议都会自动从池中扣除 Gas 费用。代理钱包只需持有 USDC 保证金资产。

工作原理

主钱包创建一个 GasPool,向其中存入资金,并将代理钱包加入白名单。此后,代理钱包调用任何交易接口时都带上一个指向主钱包的 sponsor 字段。API 构建交易,从池中提取 Gas,并返回 txKindsponsorSignature。代理钱包对交易签名后,连同两个签名一起提交。

代理钱包完全不用碰 SUI。余额不足时,从主钱包给 GasPool 充值即可。

设置

第 1 步:创建 GasPool

从主钱包出发,在一笔交易内完成 GasPool 的创建和注资:

接口: POST /api/gas-pool/transactions/create

{
  "walletAddress": "<your-primary-wallet>",
  "deferShare": false,
  "initialDepositAmount": 1000000000
}

initialDepositAmount 以 MIST 计(1 SUI = 1,000,000,000 MIST)。也可以之后再存入。

第 2 步:存入(可选充值)

接口: POST /api/gas-pool/transactions/deposit

直接存入 SUI:

或存入 USDC(或任何其他代币)。该接口会先通过 Aftermath 路由自动将其兑换为 SUI,再存入池中:

也就是说,您完全不需要持有 SUI 就能为 GasPool 注资,用手头已有的任何代币存入即可。

第 3 步:为代理钱包授权

接口: POST /api/gas-pool/transactions/grant

第 4 步:执行代付交易

代理钱包调用任何 /api/perpetuals/account/transactions/... 接口时,加入 sponsor 字段:

API 返回:

  • txKind — base64 编码的交易,供代理钱包签名

  • sponsorSignature — Gas 代付方的签名

代理钱包对 txKind 签名后,连同两个签名一起提交交易。

管理您的 GasPool

操作
接口

查询余额和白名单

POST /api/gas-pool/pool

追加存入资金

POST /api/gas-pool/transactions/deposit

提取 SUI

POST /api/gas-pool/transactions/withdraw

授予访问权限

POST /api/gas-pool/transactions/grant

撤销访问权限

POST /api/gas-pool/transactions/revoke

替代方案:本地代付

如果不想使用 GasPool,也可以自行代付:在提交前,由主钱包作为 Gas 代付方对交易载荷进行共同签名。这样无需经过 GasPool 基础设施,即可完全掌控代付流程。

Last updated