Foundry project for LangclawUsageVault — prepaid native 0G deposits and backend-authorized withdrawals on 0G mainnet (chain ID 16661).
Organization: Langclaw-AI · Backend: Langclaw-AI/backend · Frontend: Langclaw-AI/frontend
Research proof contract (SignalGraphRegistry): backend/contracts/SignalGraphRegistry.sol — deploy via npm run deploy:registry in the backend repo.
Holds user deposits. The backend credits an off-chain usage ledger after verifying Deposit events. Users withdraw only up to amounts the backend authorizes on-chain.
function deposit(bytes32 depositReference) external payable;
receive() external payable;
function authorizeWithdrawal(address payer, uint256 amount, bytes32 withdrawalId) external;
function withdraw(uint256 amount) external;
function pause() / unpause() external onlyOwner;Key events: Deposit, Withdrawal, WithdrawalAuthorized.
Source: src/LangclawUsageVault.sol
Tests: test/LangclawUsageVault.t.sol
forge install
forge build
forge testRequires Foundry.
cp .env.example .env
# LANGCLAW_USAGE_VAULT_OWNER=0x...
# LANGCLAW_USAGE_VAULT_WITHDRAWAL_AUTHORITY=0x... # backend ops wallet
source .env # or export manually
forge script script/DeployLangclawUsageVault.s.sol:DeployLangclawUsageVaultScript \
--rpc-url https://evmrpc.0g.ai \
--broadcastCopy the deployed address to LANGCLAW_USAGE_VAULT_ADDRESS in the backend .env.
Broadcast artifact: broadcast/DeployLangclawUsageVault.s.sol/16661/run-latest.json
| Backend endpoint | On-chain |
|---|---|
POST /api/usage/deposit/verify |
Reads Deposit event |
POST /api/usage/withdraw/request |
Returns vault address; user calls withdraw after authorizeWithdrawal |
authorizeWithdrawal must be called by withdrawalAuthority (set at deploy). Backend automation for this is still being wired — see the backend README.
- Vault = billing only
- Registry = research brief hash + storage URI only
Requirements spec: SMART_CONTRACT_TEAM_NOTES.md