@0xwh1sker/mantle-aa-sdk
v0.1.5
Published
EIP-7702 smart accounts for AI agents on Mantle: scoped, revocable session keys enforced on-chain, with sponsored execution through a relayer or an ERC-4337 bundler.
Maintainers
Readme
@0xwh1sker/mantle-aa-sdk
EIP-7702 smart accounts for AI agents on Mantle, from TypeScript. A human's EOA is upgraded in
place to Uniswap Calibur; the human grants each agent its own session key, whose policy (a call
allowlist, spend caps on quote assets and MNT, a per-key inventory of what the agent bought) is
enforced on chain by AgentPolicyHook. A sponsor pays the gas, through a relayer
(RelayerExecutor) or an ERC-4337 bundler with a VerifyingPaymaster (BundlerExecutor).
Proof of concept. The contracts are not audited. Mantle Sepolia (chain 5003) only. Do not use it with real funds.
Install
npm i @0xwh1sker/mantle-aa-sdk viemviem is a peer dependency: the SDK works on your own viem clients, so your project and the SDK
share one copy. Node 24 or later. The package ships the Mantle Sepolia address book:
loadDeployments() needs no arguments.
Example
import { getChain, loadDeployments, MantleAccount, PrivateKeySigner, RelayerExecutor } from "@0xwh1sker/mantle-aa-sdk";
import { createPublicClient, type Hex, http } from "viem";
const addresses = loadDeployments(); // the deployed Mantle Sepolia contracts
const client = createPublicClient({ chain: getChain(addresses.chainId), transport: http(process.env.MANTLE_AA_RPC_URL) });
const executor = new RelayerExecutor({ client, url: process.env.MANTLE_AA_SPONSOR_URL as string });
const account = new MantleAccount({
client,
root: new PrivateKeySigner(process.env.ROOT_KEY as Hex), // the human's key
executor,
keystore: { home: process.env.MANTLE_AA_HOME as string }, // where session keys are saved
});
console.log(await account.status());account.init({ grant: { policy, agentName } }) upgrades the EOA and grants the first session;
an AgentSession then runs the agent's calls, which the SDK checks against the policy before
anything is sent. Each refusal is a typed error (PolicyViolationError, LimitExceededError,
…). The full walk-through, with a policy and an agent's buy:
the SDK from TypeScript.
Related packages
@0xwh1sker/mantle-aa-cli: themantle-aacommand.@0xwh1sker/mantle-aa-sponsor: the sponsor that pays the gas.
Documentation
The repository: the quick start, the usage guide, the policy format and the design.
License
MIT
