Paymaster
Build Private Transaction
Build an apply_action transaction and get the pool fee to withdraw
POST
Overview
JSON-RPC methodpaymaster_buildTransaction with the apply_action type. Returns the fee estimate and the fee_action: the pool fee that must be withdrawn (inside the private transaction) to reimburse the paymaster. Use invoke_and_apply_action instead when a signed user call must be wrapped in the same transaction (e.g. an approve for a deposit) — the response then also contains the typed_data to sign.
The endpoint is the base URL itself (no path): https://starknet.paymaster.avnu.fi (mainnet) or https://sepolia.paymaster.avnu.fi (testnet).
Headers
Portal API key. Required for the sponsored fee modes (
sponsored, sponsored_private)Body (JSON-RPC 2.0)
paymaster_buildTransactionapply_action, or invoke_and_apply_action when a signed user call is requiredThe privacy pool address. Must be the pool whitelisted by the paymaster (exported by the SDK as
PRIVACY_POOL_ADDRESS / SEPOLIA_PRIVACY_POOL_ADDRESS)Only for
invoke_and_apply_action: { user_address, calls } — the user calls to wrap0x1{ mode: 'sponsored_private', pool_fee_token, tip? }. pool_fee_token is the token the pool fee is paid in; tip is slow | normal | fast (default normal)Optional
{ execute_after, execute_before } (unix seconds)Response
Echoes the transaction type
The pool fee to withdraw inside the private transaction:
{ type: 'withdraw', recipient, token, amount } (hex amounts)Fee estimate:
gas_token_price_in_strk, estimated_fee_in_strk, estimated_fee_in_gas_token, suggested_max_fee_in_strk, suggested_max_fee_in_gas_token (hex)Echoes the execution parameters
Only for
invoke_and_apply_action: the SNIP-12 typed data the user must sign