Installation
Copy
# npm
npm install @armory-sh/client-web3
# yarn
yarn add @armory-sh/client-web3
# pnpm
pnpm add @armory-sh/client-web3
# bun
bun add @armory-sh/client-web3
armoryPay
Copy
import { armoryPay } from '@armory-sh/client-web3';
import { Web3 } from 'web3';
const web3 = new Web3('https://...');
const account = web3.eth.accounts.wallet.add('0x...')[0];
const result = await armoryPay(
{ web3, account },
'https://api.example.com/data',
'base',
'usdc'
);
if (result.success) {
console.log(result.data);
} else {
console.error(result.code, result.message);
}
createArmoryClient
Copy
import { createArmoryClient } from '@armory-sh/client-web3';
const armory = createArmoryClient({
web3,
account,
});
const result = await armory.pay({
to: '0x...',
amount: '1000000000',
token: TOKENS.USDC_BASE,
});