Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

LEASH Backend

Onchain policy vault for agent spend allowances on Monad testnet.

Layout

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

Contracts

Contract Role
LeashFactory createVault() / createVaultFor(owner)
LeashVault depositcreateSessionspend / revoke

Session policy: total cap, optional period cap, expiry, ERC-8004 agentId, optional recipient allowlist.

Commands

# tests
forge test -vv

# build
forge build

# deploy (agent keystore must have testnet MON)
./script/deploy.sh

# API
cd api && npm install && npm run dev

Env

See .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

Deploy notes

Monskills flow: agent wallet at ~/.monskills/keystore deploys contracts.
Fund AGENT_WALLET_ADDRESS with testnet MON first (your faucet wallet already has funds).

API (after deploy)

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