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

Dynamic Gas

The DynamicGas class provides methods for allowing any non-SUI coin to be used to pay for gas on any given Transaction on the Sui network.

Initialization

const afSdk = await Aftermath.create({ network: "MAINNET" });

const dynamicGas = afSdk.DynamicGas();

Methods

getUseDynamicGasForTx()

This method accepts any completed transaction, which it will modify and return as a sponsored transaction, paying for the sender's gas in SUI, and accepting the payment for this sponsored gas from the sender in the form of the provided gasCoinType. It calls POST /api/dynamic-gas and returns the sponsored transaction bytes and sponsor signature.

const { txBytes, sponsoredSignature } = await dynamicGas.getUseDynamicGasForTx({
	tx,
	walletAddress: "0x<user_address>",
	gasCoinType: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
});

The user must sign the returned sponsored transaction, not the original transaction. Submit the user's signature and sponsoredSignature together, in that order.

Supported gas coins

Dynamic Gas accepts a range of gasCoinType values, including multiple stablecoins and Sui ecosystem tokens. Native USDC, 0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC, is a safe default for a new integration.

getUseDynamicGasForTx is the only method on DynamicGas. Neither the SDK nor the API offers a way to discover eligible gas coins, so the accepted set cannot be queried at runtime — send a gasCoinType you have confirmed and handle a rejection. Router.getSupportedCoins() is not that list: it returns the coins tradable through the router, which is a different set.

Types

Basic Types

Example Usage

In browser applications, use the connected wallet or dApp Kit to sign sponsoredTx. Execute the wallet-returned transaction bytes with the same signature ordering: [userSignature, sponsoredSignature].

Last updated