Skip to content
LogoLogo

Transport.http

HTTP transport for payments

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}`)

HTTP transport for client-side payment handling.

Usage

Behavior

  • Detects payment required using the 402 status code
  • Extracts Challenges from the WWW-Authenticate header
  • Sends Credentials using Authorization or the alternate field advertised by the Challenge
  • Preserves an existing non-Payment Authorization value when attaching another Credential field

Return type

type HttpTransport = Transport<RequestInit, Response>

Parameters

None.