Skip to content
LogoLogo

tempo

Register default Tempo intents

Choose a signing account

Create a server-only wallet.ts module, then import account wherever an example creates a local signing account.

wallet.ts
import { privateKeyToAccount } from 'viem/accounts'

export const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)

Preferred convenience function that creates both tempo.charge and Sessions method intents with shared configuration.

Use tempo(...) by default. Use tempo.common(...) only when you want to make the shared charge and Sessions behavior explicit; it is an alias for tempo(...).

Register tempo.subscription separately for recurring payments.

Usage

import { , ,  } from 'mppx/server'
import {  } from 'viem/accounts'
 
const  = ('0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef')
 
.({
  : [
    ({
      ,
      : 4217,
      : '0x20c0000000000000000000000000000000000000', // pathUSD on Tempo
      : '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      : .(),
    }),
  ],
})

This is equivalent to:

import { , ,  } from 'mppx/server'
import {  } from 'viem/accounts'
 
const  = ('0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef')
 
.({
  : [
    .({
      : '0x20c0000000000000000000000000000000000000', // pathUSD on Tempo
      : '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
    }),
    .({
      ,
      : 4217,
      : '0x20c0000000000000000000000000000000000000', // pathUSD on Tempo
      : .(),
    }),
  ],
})

Return type

type ReturnType = readonly [Method.Server, Method.Server]

A tuple of [charge, session] methods. Mppx.create accepts tuples in the methods array and flattens them automatically.

Parameters

Accepts the union of tempo.charge and tempo.session parameters. The most common are listed below.

account (optional)

  • Type: Account

Account used to sign Tempo transactions and receive payments by default.

canOffer (optional)

  • Type: Method.CanOfferFn

Returns whether each configured Tempo offer is available when an HTTP handler composes multiple offers. The hook receives the normalized, immutable payment request and a clone of the incoming Request.

chainId (optional)

  • Type: number

Tempo chain ID used for Sessions Challenges. Use 4217 for mainnet and 42431 for Moderato testnet.

currency (optional)

  • Type: Address

Default TIP-20 token address for the payment currency.

decimals (optional)

  • Type: number
  • Default: 6

Decimal places for amount parsing.

feePayer (optional)

  • Type: Account | string | true

Account or URL for sponsoring transaction fees. Pass a viem Account to co-sign locally, a URL string to delegate to a remote fee payer service, or true when the account parameter doubles as the fee payer.

getClient (optional)

  • Type: (parameters: { chainId?: number }) => MaybePromise<Client>

Function that returns a viem client for the given chain ID. Overrides the default RPC configuration.

onPaymentSuccess (optional)

  • Type: Method.OnPaymentSuccessFn<typeof tempo.Methods.charge> & Method.OnPaymentSuccessFn<typeof tempo.Methods.session>

Runs after a configured Tempo charge or Sessions result succeeds. The hook receives the normalized request, its Receipt, and the HTTP input when available. Errors don't change payment handling.

recipient (optional)

  • Type: Address

Default recipient address for payments.

testnet (optional)

  • Type: boolean

Testnet mode. Defaults the chain ID to 42431 (Tempo testnet).