Powered by Turnkey
- Catena built agentic treasury and banking infrastructure on Turnkey, giving AI agents their own accounts, payments, and treasury management. Policy guardrails are enforced at the enclave level, including tamper-proof spend limits, multi-party approvals, and agent-to-agent commerce with built-in identity verification.
Key implementation decisions
Example: autonomous payment agent
The following examples walk through three agentic payment patterns, all using the same agent wallet and policy foundation:- Stablecoin payout - Agent sends USDC to an approved recipient, covering wallet setup, policies, gas sponsorship, and balance checks.
- x402 payment - Agent responds to an HTTP 402 Payment Required response by completing an onchain payment automatically.
- MPP payment - Agent fulfills a payment request from a service using Stripe’s Machine Payments Protocol.
1. Stablecoin payout
This example assumes you’ve provisioned an agent wallet and credentials following the Agentic Wallets guide. The agent client below uses those credentials.
1
Initialize the agent client
Create a Turnkey client using the agent’s API credentials:
2
Check available balance
Before initiating a payment, the agent checks that it has sufficient funds:
3
Define a payment policy
Restrict the agent to only interact with the USDC contract. This policy is created once by an admin:The policy above restricts which contract the agent can interact with. To control the actual recipient addresses within an ERC-20 transfer, you can upload the contract ABI and write policies against individual function parameters. See Smart Contract Interfaces to learn more.
4
Send the USDC payout with gas sponsorship
With gas sponsorship enabled, the agent doesn’t need to hold ETH to pay for transaction fees. Turnkey covers gas so the agent can transact using only its USDC balance:
5
Track the transaction
Once the transaction is broadcast, the agent polls for status updates to confirm the payment landed onchain:
2. x402 payment
The x402 protocol revives HTTP’s 402 Payment Required status code as a payment rail for autonomous agents. When an agent requests a paid resource, the server responds with a 402 and payment requirements. The agent completes the onchain payment and retries the request. Turnkey plugs into this flow through@turnkey/viem, which provides a viem-compatible account that signs via the secure enclave. This replaces the raw private key that x402 clients normally use.
1
Create a Turnkey-backed viem account
Instead of using a raw private key with
privateKeyToAccount(), create a viem account backed by Turnkey:2
Register the x402 client
Pass the Turnkey account to the x402 EVM scheme. The
ExactEvmScheme accepts any viem account, so the Turnkey signer works as a drop-in replacement:3
Make a paid request
The wrapped fetch handles the full 402 flow automatically: it makes the initial request, parses the payment requirements, signs the payment via Turnkey, and retries with the payment header:
3. MPP payment
The Machine Payments Protocol (MPP) is an open standard co-authored by Tempo and Stripe that lets agents pay for services over HTTP. Like x402, an MPP-enabled server responds with a 402 challenge when payment is required. The agent signs a payment credential and retries the request. The Turnkey integration follows the same pattern as x402: themppx client accepts a viem account, so a Turnkey-backed signer works as a drop-in.
1
Create the MPP client with a Turnkey signer
Pass the Turnkey-backed viem account from the previous example to the MPP client. The
tempo method handles stablecoin payments on the Tempo network:2
Make a paid request
The MPP client handles the full 402 flow automatically: it intercepts the challenge, signs a payment credential via Turnkey, and retries the request: