Skip to main content

Make Payments with Web3.js

Make payments to Armory-protected APIs using Web3.js wallets. hooks are lifecycle callbacks. extensions are protocol fields on x402 payloads/challenges. They work together but are separate. When payment verification fails on retry (402), Armory surfaces server detail (for example insufficient_funds) in the thrown error.

Basic Payment

Armory object workflow

The createArmory object exposes .get, .post, .put, .delete, .patch, .pay, and .call. When the API responds with a 402, it selects from accepts[]. Without hooks it uses the first compatible option; add @armory-sh/client-hooks to apply chain/token/cheapest preferences. Use .pay(url, { method: 'PATCH', body }) when you need to override the HTTP method and .call(url) for the default GET.

With Browser Wallet