Skip to content
LogoLogo

Method.evm.charge

Sign EVM charge Credentials

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

Creates an EVM charge payment method for client-side EIP-3009 authorization signing.

Usage

The client signs native MPP EVM charge Challenges, route-bound x402 exact Challenges from mppx servers, and standard x402 v2 EIP-3009 Challenges without the optional mppx extension, including Challenges from official Coinbase x402 resource servers.

For x402, the client requires resource information and EIP-3009 token name and version metadata. It enforces the configured network, currency, and amount policies before signing, skips unsupported or rejected offers, and selects a later compatible offer when available.

Advanced options

Defer signer selection

Omit account when you need to inspect or approve the selected Challenge before choosing a signer. Pass the account to createCredential() after preparePayment() returns.

import { ,  } from 'mppx/client'
import type {  } from 'viem'
 
declare const : 
declare const : Response
 
const  = .({
  : [
    .({
      : [...],
      : '1.00',
    }),
  ],
  : false,
})
 
const  = await .()
const  = await .({  })

The request-local account overrides a constructor-level account. If neither location supplies a typed-data signer, Credential creation fails without signing or settling anything.

Return type

import type { Method } from 'mppx'
 
type ReturnType = Method.Client

Parameters

account (optional)

  • Type: Account

Account that signs EVM charge Credentials. Omit it to choose an account through Credential context after payment preparation.

assets (optional)

  • Type: readonly (Address | KnownAsset)[]

Legacy alias for currencies.

authorization (optional)

  • Type: { name: string; version: string }

EIP-3009 token domain metadata for custom currencies. Known assets infer this value.

currencies (optional)

  • Type: readonly (Address | KnownAsset)[]

Allowlist of EVM currencies the client accepts. Use known assets when possible so mppx can infer chain, decimals, and transfer metadata.

import {  } from 'mppx/client'
import {  } from 'viem/accounts'
 
const  = .({
  : (
    '0x0123456789012345678901234567890123456789012345678901234567890123',
  ),
  : [...], 
})

decimals (optional)

  • Type: number

Token decimal places used to parse maxAmount when currency metadata doesn't provide decimals.

maxAmount (optional)

  • Type: string

Maximum display-unit amount the client pays.

maxAtomicAmount (optional)

  • Type: string

Maximum atomic-unit amount the client pays.

networks (optional)

  • Type: readonly number[]

Allowlist of EVM chain IDs the client accepts.