Method.tempo.charge
One-time payments
Choose a signing account
Create a server-only wallet.ts module, then import account wherever an example creates a local signing account.
import { privateKeyToAccount } from 'viem/accounts'
export const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)Creates a Tempo charge payment method for client-side transaction and proof signing.
Usage
For non-zero Challenges, the client returns either a transaction or hash payload depending on mode. For zero-amount Challenges, it always returns a proof payload and skips transaction construction.
Return type
import type { Method } from 'mppx'
type ReturnType = Method.ClientParameters
account (optional)
- Type:
Account
Account to sign transactions and zero-dollar proofs with. You can override this per call using the context.
autoSwap (optional)
- Type:
boolean | { tokenIn?: Address[]; slippage?: number }
Automatically swap from a supported stablecoin (USDC.e, pathUSD) via the Tempo DEX precompile when the client lacks sufficient balance of the requested currency.
Pass true to enable, or an object for custom tokens and slippage.
clientId (optional)
- Type:
string
Client identifier used to derive the client fingerprint in attribution memos.
expectedChainId (optional)
- Type:
number
Chain ID this client accepts for Tempo charges. When set, the client rejects any Challenge with a different chainId, and uses this chain when the Challenge omits one.
expectedRecipients (optional)
- Type:
readonly string[]
Allowlist of addresses the client accepts as split recipients. When set, the client rejects any Challenge whose split recipients are not in this list, preventing a compromised server from redirecting funds.
getClient (optional)
- Type:
(parameters: { chainId: number }) => MaybePromise<Client>
Function that returns a viem client for the given chain ID.
mode (optional)
- Type:
'push' | 'pull' - Default:
'push'for JSON-RPC accounts,'pull'for local accounts
Controls how non-zero charge transactions are submitted. Zero-amount Challenges ignore this option and always use a proof payload.
'push': the client broadcasts the transaction and sends the transaction hash to the server for verification.'pull': the client signs the transaction and sends the serialized transaction to the server, which broadcasts it. This is required for server-side fee sponsorship.
resolveAccount (optional)
- Type:
ResolveAccount
Selects the account that signs this charge after the Challenge and chain are known.