clawcontract
v0.1.4
Published
AI-powered smart contract generator, analyzer, and deployer for BNB Chain
Downloads
501
Maintainers
Readme
ClawContract 🦞
AI-powered smart contract generator, analyzer, and deployer for BNB Chain
Overview
ClawContract turns natural language into production-ready, deployed, and verified smart contracts on BNB Chain. Describe what you want in plain English — ClawContract generates the Solidity code using AI, runs security analysis, deploys to BSC or opBNB, and verifies the source on BscScan — all in a single command.
Features
- Security analysis — runs Slither static analysis with an automatic regex-based fallback for environments without Python
- One-command deployment — deploy to BSC and opBNB (mainnet + testnet) with gas estimation
- Automatic verification — verify source code on BscScan and opBNBScan immediately after deployment
- Non-interactive CLI — fully automated pipeline with gas estimates, no user prompts required
- OpenClaw skill integration — register as an OpenClaw skill for chat-based contract generation and deployment
Quick Start
git clone https://github.com/your-username/ClawContract.git
cd ClawContract
pnpm install
pnpm run buildUsage
Generate a contract
clawcontract generate "ERC-20 token called VibeToken with 1M supply"Analyze a contract for vulnerabilities
clawcontract analyze ./contracts/VibeToken.solDeploy to a chain
clawcontract deploy ./contracts/VibeToken.sol --chain bsc-testnetVerify on block explorer
clawcontract verify 0xYourContractAddress --chain bsc-testnet --file ./contracts/VibeToken.solInteract with a deployed contract
clawcontract interact 0xYourContractAddress name --chain bsc-testnetCall any function on a deployed contract. Read-only functions (view/pure) are called without gas. State-changing functions are sent as signed transactions.
# Read-only call
clawcontract interact 0xABC... balanceOf 0xDEF... --chain bsc-testnet
# State-changing call
clawcontract interact 0xABC... transfer 0xDEF... 1000 --chain bsc-testnet
# Payable call (send BNB value in wei)
clawcontract interact 0xABC... fundTrade 1 --value 100000000000000 --chain bsc-testnet
# Use ABI from source file instead of stored metadata
clawcontract interact 0xABC... name --chain bsc-testnet --file ./contracts/VibeToken.solList deployments
clawcontract listList all stored deployment records. Shows address, contract name, chain, deployer, and deployment date.
# List all deployments
clawcontract list
# Filter by chain
clawcontract list --chain bsc-testnet
# Output as JSON (for scripting)
clawcontract list --jsonDelete a deployment record
clawcontract delete <address>Remove a deployment record from the local store. Shows deployment details and asks for confirmation before deleting. Orphaned ABI files are automatically cleaned up.
# Delete with confirmation prompt
clawcontract delete 0xYourContractAddress
# Skip confirmation
clawcontract delete 0xYourContractAddress --forceFull pipeline (generate → analyze → deploy → verify)
clawcontract full "staking contract for BNB with 10% APY" --chain bsc-testnetOptional flags:
--skip-deploy— stop after analysis, do not deploy or verify (useful for review before deploying)--skip-fix— do not auto-fix high-severity issues found during analysis
# Generate and analyze only — review before deploying
clawcontract full "staking contract for BNB with 10% APY" --chain bsc-testnet --skip-deployGlobal options
| Option | Description | Default |
|---|---|---|
| --chain <chain> | Target blockchain | bsc-testnet |
| --output <dir> | Output directory for generated contracts | ./contracts |
Supported Chains
| Chain | Chain ID | RPC | Explorer |
|---|---|---|---|
| BNB Smart Chain | 56 | https://bsc-dataseed.binance.org | bscscan.com |
| BNB Smart Chain Testnet | 97 | https://data-seed-prebsc-1-s1.binance.org:8545 | testnet.bscscan.com |
| opBNB | 204 | https://opbnb-mainnet-rpc.bnbchain.org | opbnbscan.com |
| opBNB Testnet | 5611 | https://opbnb-testnet-rpc.bnbchain.org | testnet.opbnbscan.com |
Architecture
src/
├── cli/ # Commander.js CLI entry point + command handlers
├── generator/ # Contract generation (template matching + Claude LLM)
├── analyzer/ # Security analysis (Slither + regex fallback)
├── deployer/ # Compilation + deployment via Hardhat + ethers.js (saves metadata)
├── verifier/ # BscScan / opBNBScan source verification
├── config/ # Chain configurations and constants
└── openclaw/ # OpenClaw skill definition for chat integrationPipeline Flow
The full command runs the entire pipeline end-to-end. If high-severity issues are found during analysis, the AI will automatically attempt to fix them (up to 3 attempts) before proceeding to deployment. Use --skip-deploy to stop after analysis, or --skip-fix to disable automatic fix attempts.
Natural Language
↓
AI Generation ─── template matching + Claude LLM
↓
Security Analysis ── Slither / regex checks
↓ ↑
AI Auto-Fix ────────┘ (up to 3 attempts if high-severity issues found)
↓
Compilation ────── Hardhat + solc
↓
Deployment ─────── ethers.js → BSC / opBNB
↓
Verification ───── BscScan / opBNBScan API
↓
Interaction ────── ethers.js read/write callsOpenClaw Integration
ClawContract ships with an OpenClaw skill that teaches OpenClaw agents how to use the CLI for chat-based contract generation and deployment. Copy or symlink src/openclaw/ into your OpenClaw workspace skills/ directory to enable it.
Configuration
Environment variables are configured via docker-compose.yml or set directly in your environment.
| Variable | Description | Required |
|---|---|---|
| CLAWCONTRACT_PRIVATE_KEY | Wallet private key for deployment (required for deploy/full) | Yes (for deploy) |
| CLAWCONTRACT_OPENROUTER_API_KEY | OpenRouter API key for AI contract generation | Yes |
| CLAWCONTRACT_OPENROUTER_MODEL | OpenRouter model (default: anthropic/claude-sonnet-4-20250514) | No |
| CLAWCONTRACT_BSCSCAN_API_KEY | BscScan / opBNBScan API key for contract verification | No |
Security: Never commit secrets to version control. When using Docker, set values in
docker-compose.ymlor pass them via environment variables.
Data: Deployment metadata is saved to
contracts/.deployments/using a directory-based store with deduplicated ABIs and an index for fast lookups. Legacy.deployments.jsonfiles are auto-migrated on first access. This directory is local and should not be committed.
Requirements
- Node.js 20.0.0 or later
- pnpm (recommended package manager)
- Python 3.8+ (optional — required for Slither static analysis; regex fallback is used if unavailable)
Hackathon
Built for the Good Vibes Only: OpenClaw Edition hackathon.
- Track: Builders' Tools
- Chain: BNB Chain (BSC + opBNB)
- Goal: Make smart contract development accessible to everyone through AI and natural language
