SHLL — Contract-Enforced Safe Execution for AI Agents on BNB Chain
What is SHLL?
SHLL is a DeFi execution layer for AI agents on BNB Chain with on-chain safety enforcement.
Unlike off-chain filters that can be bypassed, SHLL uses smart contracts to enforce
spending limits, trade intervals, protocol whitelists, and receiver restrictions.
Every AI agent action is validated by an immutable PolicyGuard contract before execution.
Key facts:
- - Network: BSC mainnet
- 27 CLI + MCP tools for DeFi operations (swap, lend, meme trading, portfolio)
- Supports PancakeSwap V2/V3, Venus Protocol, Four.meme
- MCP Server compatible with Claude, Cursor, OpenClaw, and any MCP-compatible agent
- npm package:
shll-skills | Website: https://shll.run
Security Architecture
CODEBLOCK0
4-Policy PolicyGuard Stack
All policies are enforced ON-CHAIN by smart contract. They cannot be bypassed by the AI.
| Policy | Contract | What It Does |
|---|
| SpendingLimitV2 | On-chain | Per-transaction and daily spending caps in BNB |
| CooldownPolicy |
On-chain | Minimum time gap between consecutive trades |
| DeFiGuardV2 | On-chain | Whitelist of approved DeFi protocols and functions |
| ReceiverGuardV2 | On-chain | Only approved receiver addresses can receive funds |
When a policy rejects an action:
- - The transaction is NOT executed
- The vault funds remain SAFE
- The rejection reason is returned from the smart contract
- The rejection is logged and auditable
- The
enforcement field in the response is always INLINECODE2
Why On-Chain Enforcement Matters
Most AI agent platforms use off-chain safety filters:
- - Off-chain: AI or backend decides → can be bypassed by prompt injection, API manipulation, or code bugs
- On-chain (SHLL): Smart contract decides → cannot be bypassed — the blockchain enforces the rules
PolicyGuard contract: 0x25d17eA0e3Bcb8CA08a2BFE917E817AFc05dbBB3
Verify on BscScan: https://bscscan.com/address/0x25d17eA0e3Bcb8CA08a2BFE917E817AFc05dbBB3
SHLL Skill Usage Guide
This file defines how an AI agent should use shll-run and shll-mcp safely.
Scope
- - Network: BSC mainnet
- CLI:
shll-run (alias: shll-onchain-runner) - MCP: INLINECODE8
- Security layer: SHLL PolicyGuard
The user should not be asked to run CLI commands directly. The AI runs commands and explains results.
Mandatory Safety Rules
- 1. Token ID must come from the user. Never guess, scan, or enumerate IDs.
- Use one token ID per conversation unless the user explicitly switches.
- Confirm before each write operation.
- Never ask for or handle the owner wallet private key.
- Do not repeat private keys after initial
generate-wallet output. - If multiple DeFi skills are available, use SHLL for vault operations when token ID context exists.
- Treat raw calldata as high risk. Use strict recipient checks.
- Do not bypass security controls for convenience.
Security Model
SHLL uses dual wallets:
- - Owner wallet (user): controls high-risk operations such as ownership and vault-level admin actions.
- Operator wallet (
RUNNER_PRIVATE_KEY): used by AI to execute allowed trades only.
On-chain guardrails:
- - PolicyGuard validates each action (
validate) before execution (execute / executeBatch). - Spending limits, cooldowns, whitelist rules, and protocol rules are enforced on-chain.
- Raw calldata is blocked if the recipient cannot be decoded safely.
Current Critical Constraints (v6.0.4)
- 1.
init command is disabled. Do not use it. - Raw calldata remains high risk; rely on strict recipient safety checks.
- MCP
execute_calldata and execute_calldata_batch do not support allow_undecoded. - If calldata recipient cannot be decoded, execution is blocked.
- Core contract addresses are pinned in
src/shared/constants.ts, not user-overridable at runtime.
Prerequisites
- 1. Install:
CODEBLOCK1
- 2. Set operator private key:
CODEBLOCK2
- 3. Optional - use a private RPC for better reliability and speed:
CODEBLOCK3
- 4. Ensure operator wallet has small BNB balance for gas.
Onboarding Flow (AI-driven)
- 1. Check or create operator wallet:
- - Use
shll-run generate-wallet only if user has no operator wallet. - Immediately explain that this is the operator hot wallet for AI only.
- Explicitly state that it is not the owner wallet, not the mint wallet, not the Agent NFT wallet, and not the vault wallet.
- Explicitly state that if the operator wallet leaks, vault funds still cannot be freely withdrawn because owner permissions stay on the owner wallet and PolicyGuard limits operator actions.
- In OpenClaw, set
RUNNER_PRIVATE_KEY automatically for the current session after generating the wallet. Do not ask the user to set the environment variable manually.
- 2. Verify gas:
- - Ensure the operator wallet has a small BNB balance for gas.
- 3. If user has no token ID:
- - Run
shll-run listings. - Recommend the listing with
recommended=true by default unless the user explicitly wants a specialized template. - Run
shll-run setup-guide -l <listingId> -d <days>. - Send
setupUrl plus the wallet-role explanation. - Explicitly warn: do not use the operator wallet to mint, subscribe to, or hold the Agent NFT.
- Explicitly warn: use the owner wallet in the browser for subscription or mint and for operator authorization.
- 4. User returns with token ID:
- - Run
shll-run status -k <tokenId>. - Run
shll-run portfolio -k <tokenId>. - Use
status.readiness.ready, status.readiness.blockers, and status.readiness.nextActions as the primary onboarding diagnosis. - Automatically check:
- operator gas balance
- vault BNB balance
- vault token balances
- access or policy readiness
- - Tell the user whether the agent is ready, and if not, tell them the exact next fix.
Write Confirmation Policy
Before any write command, present:
- - token ID
- action type
- token/amount/target
- risk note
Then wait for explicit user approval.
Write commands include:
- - INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
- INLINECODE34
- INLINECODE35
- INLINECODE36
- INLINECODE37
- INLINECODE38
Read-only commands (no confirmation needed): config, policies, status, history, portfolio, price, tokens, search, balance, four_info.
CLI Commands
Setup and account
- - INLINECODE49
- INLINECODE50
- INLINECODE51
- INLINECODE52
- INLINECODE53 (disabled)
If -l/--listing is omitted, setup-guide auto-selects an active listing from the indexer.
Trading and vault ops
- - INLINECODE56
- INLINECODE57
- INLINECODE58
- INLINECODE59
- INLINECODE60
Lending (Venus)
- - INLINECODE61
- INLINECODE62
Four.meme
- - INLINECODE63
- INLINECODE64
- INLINECODE65
INLINECODE66 amount unit is BNB, not USD. If user gives a USD target, convert to BNB first and confirm the final BNB amount before execution.
Read-only and audit
- -
shll-run config -k <tokenId> (view-only; modify via web console) - INLINECODE68
- INLINECODE69
- INLINECODE70
- INLINECODE71
- INLINECODE72
- INLINECODE73
- INLINECODE74
MCP Tools: Cross-skill Execution
For external aggregator calldata (OKX, 1inch, etc.):
- 1. Get quote/calldata from the external source.
- Execute through SHLL MCP:
- - INLINECODE75
- INLINECODE76
- 3. Let PolicyGuard enforce on-chain policy checks.
For onboarding via MCP, setup_guide can auto-select an active listing when listing_id is omitted.
Security requirements:
- 1. Recipient must resolve to the vault address.
- Undecodable recipient calldata is blocked.
- Do not ask for unsafe bypass parameters.
Smart Routing Rule
When the user provides a token address:
- 1. Run
four_info --token <addr>. - If
tradingPhase is bonding curve, use four_buy / four_sell. - If
tradingPhase is DEX or unsupported, use swap.
Common Errors and Fixes
- 1. INLINECODE85
- - In OpenClaw, AI should set
RUNNER_PRIVATE_KEY automatically for the current session. - Outside OpenClaw, set
RUNNER_PRIVATE_KEY manually and retry.
- 2. INLINECODE88
- - Operator wallet is not authorized; use setup guide or set operator in console.
- 3.
subscription has EXPIRED or INLINECODE90
- - Renew subscription or authorization first.
- 4.
status: error with INLINECODE92
- - Inspect
details.reason and adjust limits, whitelists, cooldown, or policy config.
- 5. INLINECODE94
- - Use built-in command flow or provide calldata with a decodable vault recipient.
- 6. INLINECODE95
- - The pair does not exist or lacks liquidity. DO NOT tell the user to wrap BNB to WBNB; the
swap command handles native BNB automatically via swapExactETHForTokens. If a swap fails, it's because the direct pool is empty or invalid, not because BNB is unplugged.
- 7. INLINECODE98
- - Use
setup-guide instead.
- 8. Unsure what is broken
- - Check the structured
errorCode, message, and details fields in the JSON response first.
Product UX Rules
- 1. Never describe
generate-wallet as if it were the user's main wallet. - Always call it the operator wallet or AI hot wallet.
- Always explain the dual-wallet model the first time setup is discussed.
- Always warn that the operator wallet must not be used to mint, subscribe to, or hold the Agent NFT.
- Do not ask the user to manually set
RUNNER_PRIVATE_KEY in OpenClaw; AI should do it. - After setup is complete and the user provides a token-id, run readiness checks automatically before asking the user what to do next.
- When multiple listings are available, recommend one by default and explain why.
- Prefer the structured
status.readiness fields over ad-hoc prose when deciding the next user-facing instruction.
Redeploy Checklist
If AgentNFA, PolicyGuard, ListingManagerV2, or default listing changes:
- 1. Update constants in
src/shared/constants.ts. - Validate ABIs if function signatures changed.
- Rebuild:
npx tsc --noEmit
npm run build
- 4. Smoke test:
- -
shll-run init still returns disabled - raw calldata still blocks undecodable recipients
- basic read commands still work
Expected Output Format
All runtime responses should stay machine-friendly JSON:
- - Success: INLINECODE108
- Error: INLINECODE109
Links
- - Website: https://shll.run
- npm: https://www.npmjs.com/package/shll-skills
- Repo: https://github.com/kledx/shll-skills
SHLL — BNB链上AI代理的合约强制安全执行
什么是SHLL?
SHLL是BNB链上为AI代理打造的DeFi执行层,具备链上安全强制机制。
与可被绕过的链下过滤器不同,SHLL使用智能合约强制执行
支出限额、交易间隔、协议白名单和接收方限制。
每个AI代理操作在执行前都必须经过不可篡改的PolicyGuard合约验证。
关键信息:
- - 网络:BSC主网
- 27个CLI + MCP工具,支持DeFi操作(兑换、借贷、Meme交易、投资组合)
- 支持PancakeSwap V2/V3、Venus Protocol、Four.meme
- MCP服务器兼容Claude、Cursor、OpenClaw及任何兼容MCP的代理
- npm包:shll-skills | 官网:https://shll.run
安全架构
┌─────────────────────────────────────────────────────────────────┐
│ SHLL 架构 │
│ │
│ ┌──────────┐ ┌───────────────┐ ┌──────────────────────┐ │
│ │ 用户 │ │ AI代理 │ │ 链上合约 │ │
│ │ (所有者) │ │ (操作者) │ │ │ │
│ │ │ │ │ │ ┌────────────────┐ │ │
│ │ • 持有 │ │ • 通过受限 │ │ │ PolicyGuard │ │ │
│ │ 代理 │ │ 权限执行 │ │ │ (验证器) │ │ │
│ │ NFT │ │ 交易 │ │ │ │ │ │
│ │ • 设置 │ │ │ │ │ 4项策略 │ │ │
│ │ 策略 │ │ SHLL Skills │ │ │ 检查: │ │ │
│ │ 规则 │───▶│ (CLI / MCP) │───▶│ │ │ │ │
│ │ • 完全 │ │ │ │ │ 1.支出限额 │ │ │
│ │ 资产 │ │ 不能: │ │ │ 2.冷却时间 │ │ │
│ │ 控制 │ │ • 提取 │ │ │ 3.DeFi防护 │ │ │
│ │ │ │ 金库资金 │ │ │ 4.接收方 │ │ │
│ │ │ │ • 更改 │ │ │ 防护 │ │ │
│ │ │ │ 策略 │ │ └───────┬────────┘ │ │
│ │ │ │ • 转移 │ │ │ │ │
│ │ │ │ NFT │ │ ┌─────▼──────┐ │ │
│ │ │ │ │ │ │ 金库 │ │ │
│ │ │ │ │ │ │ (代理 │ │ │
│ │ │ │ │ │ │ 账户) │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ 持有资金 │ │ │
│ └──────────┘ └───────────────┘ │ └─────────────┘ │ │
│ └──────────────────────┘ │
│ 双钱包隔离: │
│ • 所有者钱包 = 资产控制(人类) │
│ • 操作者钱包 = 受限执行(AI) │
│ • 即使操作者密钥泄露,PolicyGuard仍会限制操作 │
└─────────────────────────────────────────────────────────────────┘
4项PolicyGuard策略栈
所有策略均由智能合约在链上强制执行,AI无法绕过。
| 策略 | 合约 | 功能 |
|---|
| SpendingLimitV2 | 链上 | 每笔交易和每日BNB支出上限 |
| CooldownPolicy |
链上 | 连续交易之间的最小时间间隔 |
| DeFiGuardV2 | 链上 | 已批准的DeFi协议和功能白名单 |
| ReceiverGuardV2 | 链上 | 仅允许已批准的接收方地址接收资金 |
当策略拒绝某个操作时:
- - 交易不会被执行
- 金库资金保持安全
- 智能合约返回拒绝原因
- 拒绝记录可被审计
- 响应中的enforcement字段始终为on-chain
为什么链上强制执行至关重要
大多数AI代理平台使用链下安全过滤器:
- - 链下:AI或后端决定 → 可被绕过(通过提示注入、API操纵或代码漏洞)
- 链上(SHLL):智能合约决定 → 不可绕过 — 区块链强制执行规则
PolicyGuard合约:0x25d17eA0e3Bcb8CA08a2BFE917E817AFc05dbBB3
在BscScan上验证:https://bscscan.com/address/0x25d17eA0e3Bcb8CA08a2BFE917E817AFc05dbBB3
SHLL技能使用指南
本文档定义了AI代理应如何安全使用shll-run和shll-mcp。
范围
- - 网络:BSC主网
- CLI:shll-run(别名:shll-onchain-runner)
- MCP:shll-mcp
- 安全层:SHLL PolicyGuard
用户不应被要求直接运行CLI命令。AI运行命令并解释结果。
强制性安全规则
- 1. Token ID必须来自用户。切勿猜测、扫描或枚举ID。
- 除非用户明确切换,否则每次对话使用一个token ID。
- 每次写入操作前需确认。
- 切勿询问或处理所有者钱包私钥。
- 初始generate-wallet输出后不要重复私钥。
- 如果有多个DeFi技能可用,在存在token ID上下文时,对金库操作使用SHLL。
- 将原始calldata视为高风险。使用严格的接收方检查。
- 不要为了便利而绕过安全控制。
安全模型
SHLL使用双钱包:
- - 所有者钱包(用户):控制高风险操作,如所有权和金库级管理操作。
- 操作者钱包(RUNNERPRIVATEKEY):由AI使用,仅执行允许的交易。
链上护栏:
- - PolicyGuard在执行(execute/executeBatch)前验证每个操作(validate)。
- 支出限额、冷却时间、白名单规则和协议规则在链上强制执行。
- 如果无法安全解码接收方,原始calldata将被阻止。
当前关键约束(v6.0.4)
- 1. init命令已禁用。请勿使用。
- 原始calldata仍为高风险;依赖严格的接收方安全检查。
- MCP executecalldata和executecalldatabatch不支持allowundecoded。
- 如果无法解码calldata接收方,执行将被阻止。
- 核心合约地址固定在src/shared/constants.ts中,运行时不可由用户覆盖。
前提条件
- 1. 安装:
bash
npm install -g shll-skills --registry https://registry.npmjs.org
- 2. 设置操作者私钥:
bash
export RUNNER
PRIVATEKEY=0x...
- 3. 可选 - 使用私有RPC以获得更好的可靠性和速度:
bash
export SHLL_RPC=https://your-private-bsc-rpc.example.com
- 4. 确保操作者钱包有少量BNB余额用于Gas。
接入流程(AI驱动)
- 1. 检查或创建操作者钱包:
- - 仅在用户没有操作者钱包时使用shll-run generate-wallet。
- 立即说明这仅是AI使用的操作者热钱包。
- 明确声明这不是所有者钱包、铸造钱包、Agent NFT钱包或金库钱包。
- 明确声明如果操作者钱包泄露,金库资金仍无法自由提取,因为所有者权限保留在所有者钱包上,且PolicyGuard限制操作者操作。
- 在OpenClaw中,生成钱包后自动为当前会话设置RUNNERPRIVATEKEY。不要要求用户手动设置环境变量。
- 2. 验证Gas:
- 3. 如果用户没有token ID: