ClawContract
Generate, analyze, deploy, and verify smart contracts on BNB Chain via CLI.
Source & install: — clone the repo, run pnpm install && pnpm build && npm link.
Quick Start
Generate a contract:
clawcontract generate "escrow contract for peer to peer trades with dispute resolution and timeout auto release"
Full pipeline (generate → analyze → deploy → verify):
clawcontract full "escrow contract for peer to peer trades with dispute resolution and timeout auto release" --chain bsc-testnet
Deploy an existing contract:
clawcontract deploy ./contracts/VibeToken.sol --chain bsc-testnet
Interact with a deployed contract:
clawcontract interact 0xABC... name --chain bsc-testnet
List deployment records:
clawcontract list
clawcontract list --chain bsc-testnet
Delete a deployment record:
clawcontract delete 0xABC...def
References
- - Full command reference (all flags, examples, notes): See INLINECODE1
Supported Chains
| Key | Chain | Testnet |
|---|
| INLINECODE2 | BNB Smart Chain | No |
| INLINECODE3 |
BNB Smart Chain Testnet | Yes |
|
opbnb-mainnet | opBNB | No |
|
opbnb-testnet | opBNB Testnet | Yes |
Default: bsc-testnet.
Env Vars
Configure via docker-compose.yml or set directly in the environment.
| Variable | Required | Purpose |
|---|
| INLINECODE8 | Yes | AI contract generation |
| INLINECODE9 |
For deploy | Wallet for deployment — must be supplied by user |
|
CLAWCONTRACT_BSCSCAN_API_KEY | For verify | Contract verification on BscScan/opBNBScan |
|
CLAWCONTRACT_OPENROUTER_MODEL | No | Model override (default: anthropic/claude-sonnet-4-20250514) |
Artifacts
The CLI writes the following files to disk during normal operation:
| Path | When | Contents |
|---|
| INLINECODE12 | INLINECODE13 , INLINECODE14 | Generated Solidity source |
| INLINECODE15 |
deploy,
full | Deployment metadata (address, chain, tx hash) |
Safety
- - No auto-generated keys.
CLAWCONTRACT_PRIVATE_KEY must be explicitly provided by the user via environment variable. The CLI will not generate or persist a private key on its own. - Mainnet warning (non-blocking). Deployment to mainnet chains prints a bold warning about real costs but does not block on a prompt — the deploy proceeds automatically. This is by design: the CLI targets agent-driven pipelines where stdin is unavailable. Users control mainnet exposure by choosing
--chain explicitly (default is bsc-testnet). delete confirmation prompt. delete is the sole interactive command — it shows deployment details and asks Remove this deployment? (y/N). Use --force to skip the prompt (agent-friendly). This is safe because delete only removes local metadata; it cannot affect on-chain state.- Automatic fix attempts. During
full, if high-severity issues are found the AI attempts to fix and re-analyze (up to 3 rounds). This means the agent may modify generated source before deploy. Mitigations:
- Use
--skip-fix to disable auto-fix entirely.
- Use
--skip-deploy to review the final source and analysis before any on-chain action.
- Fixes only target the generated file in
contracts/; no other files are modified.
- - Accidental live-deploy risk. Because
CLAWCONTRACT_PRIVATE_KEY is mandatory for deploy and the default chain is bsc-testnet, accidental mainnet deploys require the user to both set a funded mainnet key and explicitly pass --chain bsc-mainnet or --chain opbnb-mainnet. Neither can happen silently. - Prefer testnet chains and throwaway keys for initial trials.
ClawContract
通过CLI在BNB Chain上生成、分析、部署和验证智能合约。
来源与安装: — 克隆仓库,运行 pnpm install && pnpm build && npm link。
快速开始
生成合约:
clawcontract generate 用于点对点交易、包含争议解决和超时自动释放的托管合约
完整流程(生成 → 分析 → 部署 → 验证):
clawcontract full 用于点对点交易、包含争议解决和超时自动释放的托管合约 --chain bsc-testnet
部署现有合约:
clawcontract deploy ./contracts/VibeToken.sol --chain bsc-testnet
与已部署合约交互:
clawcontract interact 0xABC... name --chain bsc-testnet
列出部署记录:
clawcontract list
clawcontract list --chain bsc-testnet
删除部署记录:
clawcontract delete 0xABC...def
参考
- - 完整命令参考(所有标志、示例、说明): 参见 {baseDir}/references/commands.md
支持的链
| 键 | 链 | 测试网 |
|---|
| bsc-mainnet | BNB智能链 | 否 |
| bsc-testnet |
BNB智能链测试网 | 是 |
| opbnb-mainnet | opBNB | 否 |
| opbnb-testnet | opBNB测试网 | 是 |
默认值:bsc-testnet。
环境变量
通过 docker-compose.yml 配置,或直接在环境中设置。
| 变量 | 是否必需 | 用途 |
|---|
| CLAWCONTRACTOPENROUTERAPIKEY | 是 | AI合约生成 |
| CLAWCONTRACTPRIVATE_KEY |
部署时需要 | 部署钱包 — 必须由用户提供 |
| CLAWCONTRACT
BSCSCANAPI_KEY | 验证时需要 | 在BscScan/opBNBScan上进行合约验证 |
| CLAWCONTRACT
OPENROUTERMODEL | 否 | 模型覆盖(默认:anthropic/claude-sonnet-4-20250514) |
产物
CLI在正常运行期间会将以下文件写入磁盘:
| 路径 | 时机 | 内容 |
|---|
| contracts/.sol | generate、full | 生成的Solidity源代码 |
| .deployments/.json |
deploy、full | 部署元数据(地址、链、交易哈希) |
安全性
- - 无自动生成的密钥。 CLAWCONTRACTPRIVATEKEY 必须由用户通过环境变量显式提供。CLI不会自行生成或持久化私钥。
- 主网警告(非阻塞)。 部署到主网链时会打印关于实际成本的粗体警告,但不会阻塞等待提示 — 部署自动进行。这是有意为之:CLI面向代理驱动的流程,其中stdin不可用。用户通过显式选择 --chain 来控制主网暴露(默认为 bsc-testnet)。
- delete 确认提示。 delete 是唯一的交互式命令 — 它会显示部署详情并询问 是否移除此部署?(y/N)。使用 --force 跳过提示(代理友好)。这样做是安全的,因为 delete 仅移除本地元数据;不会影响链上状态。
- 自动修复尝试。 在 full 过程中,如果发现高严重性问题,AI会尝试修复并重新分析(最多3轮)。这意味着代理可能在部署前修改生成的源代码。缓解措施:
- 使用 --skip-fix 完全禁用自动修复。
- 使用 --skip-deploy 在进行任何链上操作前审查最终源代码和分析结果。
- 修复仅针对 contracts/ 中生成的文件;不会修改其他文件。
- - 意外实时部署风险。 由于 CLAWCONTRACTPRIVATEKEY 是部署所必需的,且默认链为 bsc-testnet,意外的主网部署需要用户同时设置一个有资金的主网密钥并显式传递 --chain bsc-mainnet 或 --chain opbnb-mainnet。两者都不可能静默发生。
- 初次试用时建议优先使用测试网链和一次性密钥。