Gasless Trading (GasPool)
Sponsor your agent wallet's gas from a central pool
If you are running bots or programmatic strategies, you don't need to fund every agent wallet with SUI for gas. Instead, you can use a GasPool to sponsor your agent wallet's transactions from a single prepaid balance.
Think of the GasPool like a prepaid gas card. You load it with SUI (or USDC) from your primary wallet, and whenever your agent wallet executes a trade, the protocol automatically pulls the gas cost from the pool. Your agent wallet only ever needs to hold USDC collateral.
How it works
Your primary wallet creates a GasPool, deposits funds into it, and whitelists your agent wallet. From that point on, when the agent wallet calls a supported trading endpoint it includes a sponsor field containing the primary wallet and its reusable terms signature. The API builds the transaction, draws gas from the pool, and returns both a txKind and a sponsorSignature. The agent wallet signs the transaction and submits it with both signatures.
The agent wallet never touches SUI. You just top up the GasPool from your primary wallet when the balance gets low.
Setup
Step 1: Create a GasPool
From your primary wallet, create and fund a GasPool in a single transaction:
Endpoint: POST /api/gas-pool/transactions/create
{
"walletAddress": "<your-primary-wallet>",
"deferShare": false,
"initialDepositAmount": "1000000000n"
}initialDepositAmount is in MIST (1 SUI = 1,000,000,000 MIST). You can also deposit later.
Step 2: Deposit (optional top-up)
Endpoint: POST /api/gas-pool/transactions/deposit
Deposit SUI directly:
Or deposit USDC (or any other coin). The endpoint automatically swaps it to SUI via the Aftermath router before depositing:
This means you can fund your GasPool without needing to hold SUI at all. Just deposit from whatever token you already have.
Step 3: Grant access to your agent wallet
Endpoint: POST /api/gas-pool/transactions/grant
Step 4: Execute sponsored trades
When calling any /api/perpetuals/account/transactions/... endpoint from your agent wallet, include the sponsor field:
gasBudget is optional and is denominated in MIST. If omitted, the service determines the budget. Sign the exact UTF-8 message Aftermath Terms and Conditions, send its base64 representation in bytes, and reuse that signature for the wallet connection.
The API returns:
txKind— base64-encoded transaction for the agent wallet to signsponsorSignature— the gas sponsor's signature
Your agent wallet signs the txKind, then submits the transaction with both signatures.
Managing your GasPool
Check balance and whitelist
POST /api/gas-pool/pool
Deposit more funds
POST /api/gas-pool/transactions/deposit
Withdraw SUI
POST /api/gas-pool/transactions/withdraw
Grant access
POST /api/gas-pool/transactions/grant
Revoke access
POST /api/gas-pool/transactions/revoke
Share a deferred pool
POST /api/gas-pool/transactions/share
Sponsor a transaction directly
POST /api/gas-pool/transactions/sponsor
PTB composition
Set deferShare: true when creating a pool to receive gasPoolArg and sharePolicyArg, then pass those arguments to /api/gas-pool/transactions/share later in the same composed transaction. Deposits can use an existing txKind and coinArg. Withdrawals can set deferTransfer: true to receive withdrawnCoinArg for another PTB command.
The direct sponsor endpoint accepts the reusable terms signature, an optional txKind, and an optional MIST gasBudget. It returns transaction, sponsorSignature, and digest; sign transaction as the sender and submit both signatures.
GasPool failures use stable error codes: 2030 for insufficient funds, 2031 when the service is temporarily unavailable, 2032 for authorization failures, and 2033 when the transaction cannot be sponsored. Signature verification failures use 2034.
Alternative: local sponsorship
If you prefer not to use the GasPool, you can sponsor transactions yourself by having your primary wallet co-sign the transaction payload as the gas sponsor before submission. This gives you full control over the sponsorship flow without going through the GasPool infrastructure.
Last updated