Skip to main content
Version: 11.x

Interface: PaymasterAccountMethods

Defined in: src/plugins/paymaster/types/plugin.type.ts:14

The SNIP-29 paymaster members that the paymaster plugin adds to an Account.

Extended by​

Properties​

paymaster​

paymaster: PaymasterInterface

Defined in: src/plugins/paymaster/types/plugin.type.ts:19

The paymaster service of the account. The paymaster methods read it at each call, so you can replace it after the account is created.

Methods​

buildPaymasterTransaction()​

buildPaymasterTransaction(calls, paymasterDetails): Promise<PreparedTransaction>

Defined in: src/plugins/paymaster/types/plugin.type.ts:36

Build a transaction for paymaster execution

Parameters​

calls​

Call[]

Array of calls to be sponsored

paymasterDetails​

PaymasterDetails

Paymaster configuration

Returns​

Promise<PreparedTransaction>

Prepared transaction with typed data for signing

Example​

const prepared = await account.buildPaymasterTransaction(
calls,
{ feeMode: { mode: 'default', gasToken: ETH_ADDRESS } }
);

estimatePaymasterTransactionFee()​

estimatePaymasterTransactionFee(calls, paymasterDetails): Promise<PaymasterFeeEstimate>

Defined in: src/plugins/paymaster/types/plugin.type.ts:63

Estimate fees for a paymaster-sponsored transaction

Parameters​

calls​

Call[]

Array of calls to be sponsored

  • .contractAddress - Target contract address
  • .entrypoint - Function to invoke
  • .calldata - Function parameters
paymasterDetails​

PaymasterDetails

Paymaster configuration

  • .feeMode - Sponsorship mode: 'sponsored' or gas token
  • .deploymentData - Account deployment data if needed
  • .timeBounds - Valid execution time window

Returns​

Promise<PaymasterFeeEstimate>

Fee estimates in both STRK and gas token

Example​

const fees = await account.estimatePaymasterTransactionFee(
[{ contractAddress, entrypoint, calldata }],
{ feeMode: { mode: 'sponsored' } }
);

preparePaymasterTransaction()​

preparePaymasterTransaction(preparedTransaction, calls, paymasterDetails, maxFeeInGasToken?): Promise<ExecutableUserTransaction>

Defined in: src/plugins/paymaster/types/plugin.type.ts:92

Signs a transaction prepared by the paymaster, after checking it is safe to sign. The safety check needs the calls and the fee details the user actually requested, so a caller that uses this low-level method directly must pass them, the same way executePaymasterTransaction does.

Parameters​

preparedTransaction​

PreparedTransaction

the transaction returned by the paymaster.

calls​

Call[]

the calls the user requested.

paymasterDetails​

PaymasterDetails

the fee mode and related paymaster details.

maxFeeInGasToken?​

BigNumberish

optional user-approved ceiling on the gas-token fee.

Returns​

Promise<ExecutableUserTransaction>

The transaction to send to the paymaster, with the signed typed data.

Example​

const prepared = await account.buildPaymasterTransaction(calls, paymasterDetails);
const executable = await account.preparePaymasterTransaction(
prepared,
calls,
paymasterDetails
);
const { transaction_hash } = await account.paymaster.executeTransaction(
executable,
prepared.parameters
);

executePaymasterTransaction()​

executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken?): Promise<{ transaction_hash: string; }>

Defined in: src/plugins/paymaster/types/plugin.type.ts:122

Execute a paymaster-sponsored transaction

Parameters​

calls​

Call[]

Array of calls to execute

paymasterDetails​

PaymasterDetails

Paymaster configuration

  • .feeMode - 'sponsored' or gas token payment
  • .deploymentData - Deploy account if needed
  • .timeBounds - Execution validity window (UNIX timestamps)
maxFeeInGasToken?​

BigNumberish

Maximum acceptable fee in gas token

Returns​

Promise<{ transaction_hash: string; }>

Transaction hash if successful

Throws​

If gas token price exceeds maxFeeInGasToken

Throws​

If transaction parameters are modified by paymaster

Example​

const txHash = await account.executePaymasterTransaction(
calls,
{ feeMode: { mode: 'sponsored' }, timeBounds: { executeBefore: Date.now()/1000 + 3600 } },
maxFeeETH
);