Onchain policy vault for agent spend allowances on Monad testnet.
backend/
src/ # Solidity (Foundry)
LeashVault.sol # personal allowance vault
LeashFactory.sol # one vault per owner
interfaces/
mocks/ # test ERC20 only
test/ # forge tests (10 passing)
script/
Deploy.s.sol
deploy.sh # deploy via monskills keystore
abi/ # exported ABIs for frontend/API
deployments/ # chainId.json after deploy
api/ # thin read API (Express + viem)
.env # local secrets / addresses
| Contract | Role |
|---|---|
LeashFactory |
createVault() / createVaultFor(owner) |
LeashVault |
deposit → createSession → spend / revoke |
Session policy: total cap, optional period cap, expiry, ERC-8004 agentId, optional recipient allowlist.
# tests
forge test -vv
# build
forge build
# deploy (agent keystore must have testnet MON)
./script/deploy.sh
# API
cd api && npm install && npm run devSee .env.example. Public constants match Monad docs / x402 guide:
- Chain ID
10143 - RPC
https://testnet-rpc.monad.xyz - USDC
0x534b2f3A21130d7a60830c2Df862319e593943A3 - Facilitator
https://x402-facilitator.molandak.org
Monskills flow: agent wallet at ~/.monskills/keystore deploys contracts.
Fund AGENT_WALLET_ADDRESS with testnet MON first (your faucet wallet already has funds).
| Method | Path | Purpose |
|---|---|---|
| GET | /health |
RPC + factory status |
| GET | /config |
chain + addresses |
| GET | /abis |
factory + vault ABI |
| GET | /vault/:owner |
resolve vault + USDC balance |
| GET | /vault/:vault/session/:id |
session + remaining caps |
| POST | /vault/:vault/session/:id/can-spend |
preflight policy check |
| GET | /x402/demo/price |
payment requirement shape |
| GET | /x402/demo/resource |
402 unless payment header |