Skip to content

Repository files navigation

Langclaw Contracts

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.

LangclawUsageVault

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

Setup

forge install
forge build
forge test

Requires Foundry.

Deploy

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 \
  --broadcast

Copy the deployed address to LANGCLAW_USAGE_VAULT_ADDRESS in the backend .env.

Broadcast artifact: broadcast/DeployLangclawUsageVault.s.sol/16661/run-latest.json

Integration

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.

Do not mix with SignalGraphRegistry

  • Vault = billing only
  • Registry = research brief hash + storage URI only

Requirements spec: SMART_CONTRACT_TEAM_NOTES.md

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages