Appearance
Approval and refunds
First-use approval
The smart account must give the paymaster a finite native-USDC allowance before it can use prepaid gas. The public paymaster cannot sponsor its own approval because reimbursement is not yet available.
The SDK encodes the inner ERC-20 call:
ts
const approval = encodePublicPaymasterApproval(1_000_000n); // 1 USDCYour smart account then wraps that call using its own execution format. With a Viem smart account:
ts
const encodedCall = await account.encodeCalls([
{
to: INK_PUBLIC_PAYMASTER.token.address,
value: 0n,
data: encodePublicPaymasterApproval(1_000_000n),
},
]);Submit encodedCall using an owner-paid operation or another gas mechanism. The complete type-checked example in sdk/examples/encode-approval.ts creates a Viem Bundler Client without a paymaster, sends the approval, and waits for its receipt.
Prefer a finite allowance sized for expected usage rather than an unlimited approval. Monitor it with getPublicPaymasterAccountState and replenish it through your normal owner-paid path.
Refund credit
The paymaster precharges the quoted maximum during validation. After execution, unused USDC becomes pull-based refund credit owned by the smart account.
ts
const state = await getPublicPaymasterAccountState(publicClient, account.address);
console.log(state.refundCredit);To claim it, encode the paymaster call and have the smart account execute it:
ts
const claim = encodePublicPaymasterRefundClaim(recipient);
const encodedCall = await account.encodeCalls([
{to: INK_PUBLIC_PAYMASTER.paymaster, value: 0n, data: claim},
]);The account that owns the credit must make the call. The recipient may be a different address.