Skip to main content
Make payments using Ethers.js v6 wallets.

Installation

# npm
npm install @armory-sh/client-ethers

# yarn
yarn add @armory-sh/client-ethers

# pnpm
pnpm add @armory-sh/client-ethers

# bun
bun add @armory-sh/client-ethers

armoryPay

import { armoryPay } from '@armory-sh/client-ethers';
import { ethers } from 'ethers';

const signer = new ethers.Wallet('0x...');

const result = await armoryPay(
  { signer },
  'https://api.example.com/data',
  'base',
  'usdc'
);

if (result.success) {
  console.log(result.data);
} else {
  console.error(result.code, result.message);
}

createArmoryClient

import { createArmoryClient } from '@armory-sh/client-ethers';

const armory = createArmoryClient({
  provider,
  signer,
});

const result = await armory.pay({
  to: '0x...',
  amount: '1000000000',
  token: TOKENS.USDC_BASE,
});

Configuration Options

import { createX402Client } from '@armory-sh/client-ethers';

const client = createX402Client({
  signer,

  // Protocol version (default: "auto")
  protocolVersion: 2,

  // Authorization expiry in seconds (default: 3600)
  defaultExpiry: 7200,

  // Custom nonce generator - MUST return bytes32 hex string
  nonceGenerator: () => `0x${Date.now().toString(16).padStart(64, '0')}` as `0x${string}`,
});
Nonce Format: The nonceGenerator must return a bytes32 hex string (64 hex characters after 0x). This is required for EIP-712 signature compatibility with the x402 specification.