CG

Smart Contract Patterns

Updated May 29, 2026, 12:30 PM

Smart Contract Patterns

Smart Contract Patterns

The plugin includes a library of 45+ audited, gas-optimized Solidity patterns that Claude composes from when generating smart contracts. Rather than generating code from scratch every time, Claude selects and combines proven patterns -- resulting in more secure, efficient, and predictable output.

Pattern Categories

ERC-20 Tokens (10 patterns)

PatternDescription
Basic ERC-20Standard token with mint, burn, and transfer
BurnableDeflationary token with manual or automatic burn
TaxableTransfer tax with configurable fee routing
ReflectionAutomatic yield distribution to holders via reflection
GovernanceVoting-enabled token with delegation (ERC-20Votes)
Multi-ChainBridgeable token with cross-chain mint/burn mechanics
Capped SupplyHard supply cap enforced at contract level
PausableEmergency pause functionality for transfers
SnapshotPoint-in-time balance snapshots for governance and airdrops
Fee-on-TransferConfigurable buy/sell fees with LP and treasury routing

NFTs (10 patterns)

PatternDescription
ERC-721 BasicStandard NFT with metadata and enumeration
ERC-721AGas-optimized batch minting (Azuki standard)
Lazy MintOff-chain signature verification for gas-free creation
Soulbound (SBT)Non-transferable identity and credential tokens
Dynamic NFTOn-chain metadata that evolves based on conditions
ERC-1155 Multi-TokenSemi-fungible tokens for games and editions
Revenue-SharingNFTs with built-in royalty distribution to holders
Allowlist MintMerkle proof-based allowlist for presale phases
On-Chain SVGFully on-chain generative art with SVG rendering
Composable NFTNested NFTs that can own other NFTs (ERC-6059)

DeFi (10 patterns)

PatternDescription
StakingLock tokens, earn rewards over time
VestingLinear or cliff-based token vesting schedules
Bonding CurveAlgorithmic pricing based on supply
AMMConstant-product automated market maker (x*y=k)
Flash LoansUncollateralized single-transaction loans
ERC-4626 VaultTokenized yield vault (standard vault interface)
Yield AggregatorMulti-strategy vault with auto-compounding
Liquidity PoolLP token minting/burning with fee accrual
Price OracleTWAP oracle with Uniswap V3 integration
Lending PoolCollateralized lending with liquidation mechanics

Governance (5 patterns)

PatternDescription
GovernorOpenZeppelin Governor with proposal lifecycle
Multi-SigM-of-N signature wallet for treasury management
DAO TreasuryGoverned treasury with spending proposals and limits
DelegationVote delegation with weight tracking
Timelock GovernorGovernor with mandatory execution delay

Security (10 patterns)

PatternDescription
Access ControlRole-based permissions (RBAC) with admin hierarchy
Upgradeable (UUPS)Proxy pattern with upgrade authorization
TimelockTime-delayed execution for sensitive operations
EscrowConditional fund release with arbiter support
EIP-712 SignaturesTyped structured data signing for meta-transactions
Reentrancy GuardProtection against reentrancy attacks
Rate LimiterTransaction rate limiting per address
Emergency StopCircuit breaker pattern for critical failures
AllowlistAddress allowlisting with Merkle proof verification
Multi-Sig GuardRequire multiple signatures for high-value operations

How Claude Uses Patterns

When you ask Claude to generate a smart contract, it does not start from a blank file. Instead, Claude:

  1. Analyzes your requirements -- identifies which patterns apply
  2. Selects base patterns -- picks the closest matching audited pattern(s)
  3. Composes and customizes -- combines patterns and adapts parameters to your specification
  4. Validates the output -- ensures the composed contract maintains the security and gas properties of the original patterns

Example

Prompt:

"Generate an ERC-20 token with a 2% buy tax, 1% sell tax, governance voting, and a hard cap of 100 million tokens."

Claude's approach:

  • Starts with the Taxable ERC-20 pattern (buy/sell fee routing)
  • Merges in the Governance pattern (ERC-20Votes delegation)
  • Applies the Capped Supply pattern (hard cap enforcement)
  • Customizes: sets buy tax to 2%, sell tax to 1%, cap to 100,000,000 tokens
  • Outputs a single, coherent contract that inherits the audited logic from all three patterns

Why Patterns Matter

  • Audited: Every pattern has been reviewed for common vulnerabilities -- reentrancy, overflow, access control gaps, and more.
  • Gas-Optimized: Patterns use efficient storage layouts, batch operations, and minimal external calls. The ERC-721A pattern, for example, reduces batch mint gas by up to 90% compared to naive implementations.
  • Composable: Patterns are designed to combine cleanly. Inheritance hierarchies, storage slots, and function signatures are structured to avoid conflicts when merging multiple patterns.
  • Battle-Tested: Patterns reflect real-world deployment conventions used across major DeFi and NFT protocols.

Extending Patterns

You can ask Claude to modify any pattern or combine them in novel ways:

"Take the staking pattern but add an ERC-721 NFT boost -- stakers who hold an NFT from our collection get 2x rewards."

"Create an ERC-1155 marketplace with built-in royalty enforcement and a bonding curve for edition pricing."

Claude will compose from the relevant base patterns and generate the custom logic needed to connect them.

View original source