AWS Builder Center
I Gave an AI Agent a Wallet — Here's How I Kept It Honest

I Gave an AI Agent a Wallet — Here's How I Kept It Honest

An AgentCore Runtime + Strands agent settles multi-currency invoices through Sera's on-chain FX protocol, auto-executing under $20 and asking a human above it.

Cloud Engineer
A few weeks ago a promo image for Sera.cx crossed my feed: a green card claiming on-chain settlement across 120-plus stablecoins, plus an MCP server called sera-mcp released under MIT so agents can call it directly.

What actually caught my attention wasn't the currency count, it was the auth model. testnet.sera.cx has no signup flow. There's no account creation, no password. A private key is the identity, and you mint an API key by signing an EIP-712 message with it. For a human that's a slightly unusual UX. For an AI agent it's close to ideal: there's no login form to click through, just a keypair to hand over and an API to call.
That's what pushed me to build sera-gate-agent: an agent that settles multi-currency invoices over Sera, auto-executing small payments and stopping for a human above a threshold. It reuses the approval-gate infrastructure from an earlier project of mine, wallet-agent (AgentCore Runtime, Strands, Next.js, DynamoDB, Vercel), with the settlement logic swapped out for Sera MCP.
Architecture:

Flow:

YouTube:


Two safety nets, not one

The threshold logic is a single pure function, no AWS dependencies at all:
DEFAULT_THRESHOLD_USD = "20"

def decide_auto_or_approval(amount_usd):
threshold = Decimal(os.environ.get("SERA_GATE_AUTO_THRESHOLD_USD", DEFAULT_THRESHOLD_USD))
return "AUTO" if amount_usd <= threshold else "REQUIRE_APPROVAL"
That threshold only controls the UX layer, though. If the code has a bug or the signing key leaks, the thing that actually caps the blast radius on-chain is Sera's own  POLICY_PRESET . I run  standard  ($5,000/tx, $50,000/day) on the Sera side and keep the agent's own threshold at $20, so during any demo or real run the agent-side gate always fires first. Two independent layers, neither one trusting the other to be the only line of defense.
The part I actually think matters more, though, is that the LLM never gets to call the execution tools directly. sera-mcp's mutating tools —  execute_swap ,  convert_and_send ,  pay_invoice , and a handful of others — are excluded from what's exposed to the agent. Only a Python function called  settle_invoice_tool  can reach them, and the threshold check lives inside that function, not in a system prompt instruction. Telling Claude "always ask before spending more than $20" mostly works, but "mostly" isn't a safety property. Making the execution path structurally unreachable except through one gated function is.

The permit that wasn't automatic

sera-mcp's  convert_and_send  signs the EIP-712 intent for you under local signer mode, which is genuinely convenient. What it doesn't automate is the ERC-2612 permit some tokens require for the deposit step — I only found this out because a real testnet call came back with  Quote requires an EIP-2612 permit . The fix was to stop trusting the one-shot helper and assemble the flow manually:  get_quote , sign the permit myself if one is required, then  execute_swap .
quote = sera_mcp.call_tool(client, "sera.get_quote", {...})
exec_args = {"uuid": quote["uuid"], "route_params": quote["route_params"]}

permit_info = quote.get("permit")
if permit_info and permit_info.get("permit_required"):
eip712 = permit_info["eip712"]
exec_args["permit_signature"] = permit.sign_typed_data(signer_key, eip712)
exec_args["permit_deadline"] = eip712["message"]["deadline"]

result = sera_mcp.call_tool(client, "sera.execute_swap", exec_args)
The lesson generalizes past this one MCP server: the more convenient a wrapper looks, the more worth checking exactly what it's automating underneath, because the gap only shows up against a real testnet call, never in the docs.

What actually broke on the way to production

Getting this onto AgentCore Runtime and Vercel surfaced three separate rough edges, none of them big individually.
 agentcore configure  defaults to direct code deploy, a bare Python runtime with no room for a Node.js sidecar — and sera-mcp is Node.js.  --deployment-type container  has to be passed explicitly or the Node process silently has nowhere to run.
On the Vercel side, the OIDC Federation token doesn't show up as  process.env.VERCEL_OIDC_TOKEN  the way you'd expect from local dev. Inside a Next.js API route it only arrives on the request header  x-vercel-oidc-token , and getting AWS credentials out of it means going through  @vercel/oidc-aws-credentials-provider 's  awsCredentialsProvider()  rather than reading the env var directly.
The one that cost the most time was the response stream from  InvokeAgentRuntimeCommand . On Vercel's Node.js runtime,  resp.response  isn't a standard  ReadableStream  — it's wrapped by the AWS SDK's  sdkStreamMixin . Calling  getReader()  on it fails in a way that doesn't obviously point at the real problem; the fix was  transformToString()  instead.
None of these are exotic. They're the kind of thing that costs twenty minutes each once you know the answer, and much longer before that.




Where it landed

End to end, this now runs on Sepolia: a $15 invoice auto-executes, a $50 invoice issues an approval card that a human clicks through in the browser, and both settle on-chain. Switching the approval store from a local JSON file to DynamoDB didn't require touching the settlement logic at all —  route_summary  just lands as a nested map in the item, same as everything else the agent writes.
The interesting part, to me, wasn't proving that an AI agent can move money on-chain. It's that "how much autonomy this agent gets" turned out to be something I could express as a couple of environment variables and one gated function, rather than something I had to hope a prompt would enforce.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article