Onchain Agent Wallets

v0.1.1
io.github.nirholas/onchain-agent-wallets Checked 14 hours ago Published 1 month ago

Give an AI agent a Solana spending allowance instead of your key.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

create_agent_wallet Give an agent a wallet with an on-chain spending limit

Create an agent wallet on Solana. Generates a fresh keypair for the agent, creates a vault token account that YOU own (derived deterministically from your address plus the agent id), and delegates a capped allowance over it to the agent. The SPL Token program enforces that cap: the agent cannot spend past it, and every spend decrements it. You keep custody, you can revoke in one instruction, and you can withdraw the balance without the agent. Set guardrails (per_tx, daily, allowlists, expiry) in the same call. Signs with OWNER_SECRET_KEY if configured, otherwise returns an unsigned transaction…

ParameterTypeDescription
allowance *stringThe on-chain ceiling, in whole tokens (e.g. "100"). The agent can never spend more than this without a new approval.
id *stringShort slug naming the agent, lowercase letters/digits/hyphens. Becomes the on-chain vault seed.
agent_secretstringReuse an existing agent keypair (base58 or JSON array) instead of generating one.
allow_hostsarrayGuardrail: only these hosts may be paid over x402. Subdomains included. Empty means unrestricted.
allow_recipientsarrayGuardrail: only these addresses may receive funds. Empty means unrestricted.
confirmbooleanSet true to actually build and broadcast. Without it you get the summary only.
confirm_overstringGuardrail: spends above this amount need an explicit confirm:true from a human.
dailystringGuardrail: maximum spend per rolling 24 hours, in tokens.
expires_atstringGuardrail: ISO timestamp after which every spend is refused.
fee_solstringSOL to send the agent so it can pay its own transaction fees. Default "0.02". This is the only value the agent itself holds.
labelstringHuman-readable name for your own reference.
mintstringSPL mint to spend. Defaults to USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v on mainnet).
ownerstringYour wallet address. Omit to use the configured OWNER_SECRET_KEY. Pass it to keep the key off this machine and sign in your wallet.
per_txstringGuardrail: maximum single spend, in tokens.
secretstringOwner secret key for this call only, overriding OWNER_SECRET_KEY.

fund_agent_wallet Top up an agent's vault, and its fee SOL

Move tokens from your wallet into the agent vault, and optionally send the agent a little SOL for its own transaction fees. The vault stays owned by you; funding it does not raise the delegated allowance, so the agent still cannot spend past its ceiling. Requires confirm:true to broadcast.

ParameterTypeDescription
id *stringThe agent wallet to fund.
amountstringTokens to move into the vault, in whole units (e.g. "50").
confirmbooleanSet true to broadcast.
secretstringOwner secret key for this call only.
solstringSOL to send the agent for transaction fees (e.g. "0.02").

approve_agent_allowance Set the agent's on-chain spending ceiling

Set how much the agent may spend from the vault, enforced by the SPL Token program. This REPLACES the existing allowance, it does not add to it: passing "50" leaves the agent with exactly 50 regardless of what it had before. Use it to raise, lower, or refill an allowance. Requires confirm:true to broadcast.

ParameterTypeDescription
allowance *stringThe new total allowance in whole tokens. "0" is equivalent to a revoke.
id *stringThe agent wallet.
confirmbooleanSet true to broadcast.
secretstringOwner secret key for this call only.

set_guardrails Change an agent's spending rules

Set the rules this server enforces before it signs a spend: per-transaction cap, rolling 24h cap, allowed recipients, allowed x402 hosts, an expiry, a confirm-above threshold, and a pause switch. Takes effect immediately, costs nothing, and needs no transaction. Only the fields you pass change; pass null to clear one. Empty allowlists mean unrestricted. These sit ON TOP of the on-chain allowance, which no software here can raise: to change that ceiling use approve_agent_allowance, and to cancel it entirely use revoke_agent_wallet.

ParameterTypeDescription
id *stringThe agent wallet.
allow_hostsOnly these hosts may be paid over x402, subdomains included. Empty or null means unrestricted.
allow_recipientsOnly these addresses may receive funds. Empty or null means unrestricted.
confirm_overstring | nullSpends above this need an explicit human confirm:true. null clears it.
dailystring | nullMaximum spend per rolling 24 hours. null clears it.
expires_atstring | nullISO timestamp after which every spend is refused. null clears it.
pausedbooleantrue stops every spend immediately. false resumes.
per_txstring | nullMaximum single spend, in tokens. null clears it.

agent_pay Let the agent send tokens inside its limits

Send tokens from the agent vault to a recipient, signed by the agent as the on-chain delegate. Every guardrail is checked first (per-transaction cap, rolling daily cap, recipient allowlist, expiry, pause) and the SPL Token program enforces the remaining allowance underneath. A refusal explains which rule stopped it. Requires confirm:true to broadcast.

ParameterTypeDescription
amount *stringAmount in whole tokens (e.g. "1.25").
id *stringThe agent wallet spending the money.
to *stringRecipient wallet address. Their associated token account is created if needed.
confirmbooleanSet true to broadcast.
memostringNote recorded in the local spend log.

pay_x402 Let the agent pay for an x402 API out of its allowance

Call an HTTP endpoint that charges with x402, paying from the agent allowance on Solana. The price is read from the unpaid 402 response first, so the guardrails (per-transaction cap, daily cap, host allowlist, expiry, pause) see the real amount before anything moves. The agent is topped up for exactly that amount from the vault, pays, and is left empty. If the endpoint is not charging, the content comes back with no payment at all. Requires confirm:true when the price is above the confirm threshold or confirmation is on.

ParameterTypeDescription
id *stringThe agent wallet paying.
url *stringThe resource to call.
bodystringRequest body, for POST/PUT/PATCH.
confirmbooleanSet true to authorize payment.
headersobjectExtra request headers.
max_pricestringRefuse if the resource asks for more than this, in whole tokens. A ceiling for this call only.
methodstringHTTP method. Default GET.

withdraw_from_vault Move funds out of an agent vault back to the owner

Withdraw tokens from an agent vault back to your own wallet. The vault is yours, so this always works, with or without a live delegation, and the agent cannot block it. Leaves the allowance untouched: lowering the balance already limits what the agent can spend. Requires confirm:true to broadcast.

ParameterTypeDescription
id *stringThe agent wallet.
amountstringTokens to withdraw. Omit to withdraw the entire balance.
confirmbooleanSet true to broadcast.
secretstringOwner secret key for this call only.

revoke_agent_wallet Revoke the agent's spending authority on-chain

Cancel the agent's delegation on-chain. After this the SPL Token program refuses every transfer the agent signs, permanently, until you approve a new allowance. Pass withdraw:true to also sweep the vault balance back to your wallet in the same transaction. For an instant free stop that needs no transaction and no SOL, use set_guardrails with paused:true instead: that blocks this server, while revoke blocks the chain itself. Requires confirm:true to broadcast.

ParameterTypeDescription
id *stringThe agent wallet to revoke.
amountstringWithdraw only this much instead of the whole balance.
confirmbooleanSet true to broadcast.
secretstringOwner secret key for this call only.
withdrawbooleanAlso move the vault balance back to your wallet. Default false.

agent_wallet_status Live status of an agent wallet

Show an agent wallet as it actually stands on-chain: vault balance, how much of the delegated allowance is left, what it can spend right now, its fee SOL, the guardrails in force, spend totals for the last 24 hours, and any warnings (revoked, expired, paused, out of fee SOL, allowance unbacked by balance). Read-only.

ParameterTypeDescription
id *stringThe agent wallet.

list_agent_wallets Every agent wallet on this machine

List the agent wallets configured here, each with its live vault balance, remaining on-chain allowance, and guardrails. Read-only.

ParameterTypeDescription
ownerstringOnly agents belonging to this owner address.

spend_log An agent's spend history, including refusals

The audit trail for one agent: every spend that went through and every one the guardrails refused, with the amount, destination, transaction signature, and the rule that decided it. Refusals are recorded on purpose, so you can see what an agent tried to do. Read-only.

ParameterTypeDescription
id *stringThe agent wallet.
limitintegerHow many entries to return, newest first. Default 50.
onlystringFilter by outcome. Default all.
sincestringISO timestamp: only entries at or after this time.

deploy_agent_onchain Publish the agent on-chain with its payment address

Mint the agent an on-chain identity in the Metaplex Agent Registry on Solana, carrying its EIP-8004 registration document, an x402Support flag, and on-chain attributes naming its payment address, its vault, and the token it accepts. After this the agent is discoverable on metaplex.com/agents and any counterparty can read where to pay it. Costs about 0.007 SOL and needs an owner signing key (set OWNER_SECRET_KEY or pass `secret`); to mint from Phantom or a Ledger instead, use prepare_agent_mint in @three-ws/metaplex-agent-mcp. Requires confirm:true to broadcast.

ParameterTypeDescription
id *stringThe agent wallet to publish.
confirmbooleanSet true to broadcast.
descriptionstringWhat this agent does.
imagestringImage URL for the asset.
model_urlstringGLB avatar URL, rendered on metaplex.com/agents.
namestringOn-chain name. Defaults to the agent label or id.
secretstringOwner secret key for this call only.
servicesarrayEndpoints this agent serves, e.g. its own x402 API.

export_agent_runtime Export an agent wallet as a runnable MCP config

Produce the config that puts this agent wallet in front of a model: an mcp.json block, the equivalent claude mcp add command, the agent identity card (payment address, vault, token, limits), and the x402 details a counterparty needs to bill it. By default no key material is included, so the output is safe to paste into a repo or a ticket. Pass include_secret:true only when moving the agent to another machine.

ParameterTypeDescription
id *stringThe agent wallet to export.
include_secretbooleanInclude the agent's secret key. Anyone holding it can spend up to the allowance. Default false.

send_signed_transaction Broadcast a transaction your wallet signed

Broadcast a base64 transaction that Phantom, Solflare, Backpack, or a Ledger already signed, and wait for confirmation. This is how the owner side works without any secret key on this machine: any tool that returns "prepared_for_wallet" hands you a transaction_base64 to sign and pass here. Blockhashes expire in about 60 seconds, so if this reports an expired blockhash, re-run the tool that prepared it.

ParameterTypeDescription
signed_transaction *stringThe signed transaction, base64-encoded, as your wallet returned it.