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.

If you need to close, top up, or stream a single channel explicitly, use tempo.session.manager() instead.

Usage

import { ,  } from 'mppx/client'
import {  } from 'accounts'
 
const  = .({ : false }) // Avoid double 402 handling; mppx is configured below.
await .({ : 'wallet_connect' })
 
.({
  : [
    ({
      : .({ : true }),
      : [4217], // Tempo mainnet
      : .,
    }),
  ],
})

This is equivalent to:

import { ,  } from 'mppx/client'
import {  } from 'accounts'
 
const  = .({ : false }) // Avoid double 402 handling; mppx is configured below.
await .({ : 'wallet_connect' })
 
.({
  : [
    .({
      : .({ : true }),
      : .,
    }),
    .({
      : .({ : true }),
      : .,
    }),
  ],
})

Standalone session manager

tempo.session.manager() creates a standalone Sessions manager with explicit .fetch(), .topUp(), .close(), .sse(), and .ws() methods. It does not register a method in Mppx.create; it owns one channel lifecycle directly.

import {  } from 'mppx/client'
import {  } from 'accounts'
 
const  = .({ : false }) // Avoid double 402 handling; mppx is configured below.
await .({ : 'wallet_connect' })
 
const  = ..({
  : .({ : true }),
  : .,
  : '1',
})
 
const  = await .('https://api.example.com/resource')
await .()

See tempo.session.manager for the full API.

Return type

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

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 to sign transactions and vouchers with.

allowCustomEscrow (optional)

  • Type: boolean
  • Default: false

Accepts a noncanonical Session reserve contract advertised by the server. This option affects the generated tempo.session method only.

allowedChainIds (optional)

  • Type: readonly number[]

Allowlist of Tempo chain IDs for both charge and Session Credentials. Use [4217] for mainnet. A single entry supplies an omitted Challenge chain; multiple entries require the Challenge or resolved client to select one. An empty array rejects every chain.

channelStore (optional)

  • Type: ChannelStore

Store for reusable Sessions channels. Defaults to an in-memory store.

expectedChainId (optional)

  • Type: number

Tempo chain ID this client accepts for both generated methods. Charge payments use it as an exact chain pin. Sessions receive the equivalent one-chain allowlist.

When allowedChainIds is also set, it must include expectedChainId; otherwise the generated Session method rejects every chain.

getClient (optional)

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

Function that returns a viem client for the given chain ID.

maxDeposit (optional)

  • Type: string

Maximum deposit in human-readable units. Caps server-suggested channel opens and automatic top-ups.

resolveAccount (optional)

  • Type: ResolveAccount

Selects the account that signs a Tempo charge or Sessions Credential after the Challenge is known.