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 = new Aftermath("MAINNET");
await afSdk.init(); // initialize provider
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.
const { txBytes, sponsoredSignature } = await dynamicGas.getUseDynamicGasForTx({
tx,
walletAddress: "0x<user_address>",
gasCoinType: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
});Types
/**
* Represents the response from the dynamic gas service, typically returning
* updated transaction bytes and possibly a sponsored signature if the
* transaction gas is being partially or fully sponsored.
*/
export interface ApiDynamicGasResponse {
/**
* The modified transaction bytes that incorporate a gas coin or sponsor information.
*/
txBytes: SerializedTransaction;
/**
* A signature used to sponsor or verify the updated transaction, if applicable.
*/
sponsoredSignature: string;
}
/**
* Represents the body payload sent to the dynamic gas service,
* which includes the serialized transaction and any user-provided
* gas configuration (e.g., coin type).
*/
export interface ApiDynamicGasBody {
/**
* The serialized transaction block in base64 or similar format.
*/
serializedTx: SerializedTransaction;
/**
* The address of the user for whom the dynamic gas is being set.
*/
walletAddress: SuiAddress;
/**
* The coin type to be used for gas payment (e.g., "0x2::sui::SUI").
*/
gasCoinType: CoinType;
}Basic Types
Example Usage
Last updated