CLAUDE.md Template: Smart Contract Project
Bob Makes This Easier
If you install Bob (
claude mcp add opnet-bob --transport http https://ai.opnet.org/mcp),
you get all OP_NET knowledge automatically through MCP tools. The CLAUDE.md below is still
useful for project-specific rules, but Bob handles the OP_NET-specific patterns for you.How to Use This Template
- Click the Download button below to save this as a file
- Put the downloaded file in your project folder
- Rename it to
CLAUDE.md(if it isn't already) - Open Claude Code in that folder — it will read the file automatically
Or just tell Claude Code: Create a CLAUDE.md file for an OPNet smart contract project. With Bob installed, it will generate one for you.
Below is the template content. Everything below the line should be in your CLAUDE.md file:
CLAUDE.md — OPNet Smart Contract Project
#Project Description
This is a smart contract project built on Bitcoin Layer 1 with OP_NET. Contracts are written in AssemblyScript and compiled to WebAssembly.
#Required Reading
Before writing ANY contract code, read the opnet-development skill docs:
- Read
contracts-guidelines.mdfor contract patterns - Read the relevant contract type docs (OP20, OP721, etc.)
- Read
setup-guidelines.mdfor correct package versions - Read
audit-guidelines.mdbefore finalizing any contract
#Package Rules
#ALWAYS Use
@btc-vision/bitcoin— Bitcoin library (OPNet fork)@btc-vision/ecpair— EC pair library (OPNet fork)@btc-vision/transaction— Transaction constructionopnet— OPNet SDK and provider@btc-vision/btc-runtime— Smart contract runtime
#NEVER Use
bitcoinjs-lib— wrong Bitcoin library, will break transactionsecpair— wrong EC pair librarytiny-secp256k1— use@noble/curvesinsteadethersorweb3— Ethereum libraries, wrong ecosystemexpress,fastify,koa— wrong backend framework
#Package Versions
- DO NOT guess package versions
- Check the opnet-development skill setup-guidelines for exact versions
- Do not use
latestor^ranges — use pinned versions from the docs
#Smart Contract Rules
#Architecture
- Contracts are classes extending the appropriate base (OP20, OP721, etc.)
- The constructor runs on EVERY interaction, not just deployment
- Use
onDeployment()for one-time initialization (minting, setting owner, etc.) - All state is stored via storage pointers
#Safety
- Use SafeMath for ALL u256 arithmetic operations — no raw +, -, *, /
- No
whileloops — all loops must be bounded with a known max iteration count - No iterating over all map keys — store aggregates separately
- Every storage pointer must have a unique numeric value — collisions corrupt data
#Access Control
- Owner-only functions must check
Revert.ifNotOwner(this, msg.sender) - Public functions that modify state should validate all inputs
- Check for zero-address and zero-amount where applicable
#Coding Standards
- TypeScript / AssemblyScript only — no raw JavaScript
- Every public function should have clear parameter types
- Use descriptive storage pointer names with comments showing their numeric ID
- Handle all arithmetic edge cases (overflow, underflow, division by zero)
#Build Process
npm install— install dependenciesnpm run build— compile contract to WebAssembly- Output:
.wasmfile in the build directory
#Deployment
- Use testnet for testing:
https://testnet.opnet.org - Use mainnet for production:
https://mainnet.opnet.org - Read the opnet-cli skill docs for deployment commands
#Before Finalizing
- Run the full audit checklist from the skill docs
- Check all storage pointers are unique
- Verify SafeMath is used everywhere
- Confirm no unbounded loops exist
- Test all functions on testnet before mainnet
Ready to test your knowledge?
20 questions covering everything from vibecoding basics to shipping a complete dApp.