ClawGuard Documentation
ClawGuard is a Layer 2.5 security middleware that wraps any OpenClaw agent's tool_dispatch function to enforce declarative capabilities, stop unauthorized actions, and anchor identities to ENS and 0G Storage.
SKILL.md manifest. ClawGuard hashes it, anchors it on-chain, and uses it at runtime to gate tool access. Violations are pushed to an append-only 0G File Storage audit trail.Getting Started
Follow these steps to integrate ClawGuard into a new or existing OpenClaw project from scratch.
Step 1: Installation
Install the core middleware and CLI directly into your project:
Step 2: Environment Configuration
Create a .env file in your project root. You must provide a funded wallet for the 0G Galileo and Sepolia ENS testnets:
ZG_PRIVATE_KEY=your_hex_private_key_here
ZG_CHAIN_RPC=https://rpc-testnet.0g.ai
ZG_INDEXER_RPC=https://indexer-storage-testnet-turbo.0g.ai
# Ethereum Sepolia Config
ETH_SEPOLIA_RPC=https://sepolia.infura.io/v3/your_project_id
REGISTRY_ADDRESS=0x2205AC38725F42d9da0ffaDD94166B5E5b83010A
Step 3: Define Capabilities (SKILL.md)
Create a SKILL.md file in your agent's directory to declare what it's allowed to do:
## Allowed Tools
- web.fetch
- data.parse_json
Step 4: Publish Manifest
Use the CLI to publish your SKILL.md. This computes the cryptographic hash, stores the JSON to 0G, and registers it to ENS.
The CLI will output an ENS name like my-agent.skills.clawhub.eth. Use this in the next step.
SDK Reference
wrapWithClawGuard()
The primary entry point. Wraps your agent's execution layer.
const safeDispatch = wrapWithClawGuard(agent.tool_dispatch, {
agentId: 'defi-monitor-agent',
ensName: 'defi-reader.skills.clawhub.eth',
auditLog: true,
failOpen: false, // Rule S-01: block all calls if manifest fetch fails
});
// Optional: intercept violations
addViolationHandler(safeDispatch, (event) => {
console.error('[SECURITY]', event.blockedTool, 'blocked');
});
CLI Toolchain
The CLI manages the lifecycle of your agent manifests.
clawguard publish <path>
Parses SKILL.md, hashes it, uploads to 0G, and registers on ENS.
clawguard inspect <ens-name>
Reads and verifies the manifest live from the network.
⛔ DENIED: "wallet.transfer" is explicitly blocked for "defi-reader"
clawguard verify <path>
Runs 0G Compute sealed inference to verify code behavior matches manifest.
SKILL.md Format
Capabilities are defined declaratively in Markdown.
Read-only DeFi market data agent.
## Allowed Tools
- wallet.read_balance
- web.fetch
- data.parse_json
## Blocked Tools
- wallet.transfer
- shell.exec
## Constraints
- max_external_calls: 10
Architecture
1. ENS Resolution
ClawGuard looks up
skill.clawhub.ethon Sepolia to retrieve the 0GstorageKey(Merkle Root) andmanifestHash.2. Zero-Trust Fetch
The JSON manifest is fetched from the 0G File Storage Indexer REST API.
3. Cryptographic Verification
The downloaded manifest is hashed via SHA-256. If it doesn't match the ENS anchor, execution fails closed (Rule S-03).
4. Interception & Audit
Any attempt to call a tool in the blocked list results in a thrown exception and an immutable audit event uploaded back to 0G Storage.