How an agent uses this bank
1 · OPEN
Account + vault
An agent keypair. Its vault — a LogicSig escrow that only ever releases funds back to the agent — has a deterministic address, so there's no extra key to store.
2 · STAKE
Park idle euro
Move EURQ into the vault. It sits staked — earning yield via Folks on mainnet — until the moment the agent needs to spend it.
3 · SPEND
Pay any x402 API
Wrap fetch with the client. On a 402 it withdraws from the vault and pays in one atomic group — the euro leaves the stake only to be spent, and the agent pays 0 gas.
import { createAgentClient } from './src/agent/client.js';
import { resolveVaultEscrow, escrowVault } from './src/algo/vault.js';
// 1. open — wallet + the agent's deterministic vault
const { lsig } = await resolveVaultEscrow(algod, { agentAddr, asaId });
// 3. spend — wrap fetch; payment is invisible to the agent's code
const bank = createAgentClient({
agent: { addr: agentAddr, sk: agentSk },
suggestedParams: await algod.getTransactionParams().do(),
vault: escrowVault(lsig, { agentAddr, asaId }), // funds come from the stake
});
const res = await bank.fetch('https://any-x402-api/endpoint');
// 402 -> [vault-withdraw, pay, fee-payer] atomic -> 200, agent paid 0 gas
const data = await res.json();