Skip to main content

Overview

Retrieves smart contract templates with deployment scripts for Cronos development. Tool Name: get_contract_template

Parameters

action
enum
required
Action to performOptions: "get", "search", "list", "deploy-config"
template_id
string
Template ID (required for "get" action)
query
string
Search query (required for "search" action)
category
enum
Filter by categoryOptions: "token", "defi", "nft", "dao", "utility"

Available Templates

Template IDNameDescription
erc20-basicBasic ERC-20 TokenStandard fungible token
erc20-mintableMintable ERC-20Token with minting capability

Response (Get Action)

{
  "found": true,
  "action": "get",
  "templates": [
    {
      "id": "erc20-basic",
      "name": "Basic ERC-20 Token",
      "category": "token",
      "solidity_version": "^0.8.20",
      "use_cases": [
        "Create utility token",
        "Project governance token",
        "Reward points system"
      ],
      "contract_code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n...",
      "deployment_script": "const { ethers } = require('hardhat');\n...",
      "interaction_examples": {
        "read": ["balanceOf(address)", "totalSupply()", "allowance(owner, spender)"],
        "write": ["transfer(to, amount)", "approve(spender, amount)"]
      },
      "dependencies": ["@openzeppelin/contracts"],
      "github_source": "https://github.com/cronos-labs/contract-templates"
    }
  ],
  "commands": {
    "deploy": "npx hardhat run scripts/deploy.js --network cronos_testnet",
    "verify": "npx hardhat verify --network cronos_mainnet CONTRACT_ADDRESS ...ARGS",
    "test": "npx hardhat test"
  }
}

Example Usage

Get Specific Template

result = use_mcp_tool(
    server_name="cato",
    tool_name="get_contract_template",
    arguments={
        "action": "get",
        "template_id": "erc20-basic"
    }
)

Search Templates

result = use_mcp_tool(
    server_name="cato",
    tool_name="get_contract_template",
    arguments={
        "action": "search",
        "query": "nft"
    }
)

List by Category

result = use_mcp_tool(
    server_name="cato",
    tool_name="get_contract_template",
    arguments={
        "action": "list",
        "category": "token"
    }
)

Get Deployment Config

result = use_mcp_tool(
    server_name="cato",
    tool_name="get_contract_template",
    arguments={
        "action": "deploy-config"
    }
)

Template Details

Each template includes:

Contract Code

Production-ready Solidity code

Deployment Script

Hardhat deployment script

Interaction Examples

Common function calls

Dependencies

Required npm packages

Template Categories

🪙 Token Templates

Basic ERC-20 TokenStandard fungible token implementation with:
  • Fixed supply
  • Transfer functionality
  • Approval mechanism
  • OpenZeppelin base
Use cases: Utility tokens, governance tokens, reward systems
Mintable ERC-20ERC-20 with minting capability:
  • Owner can mint new tokens
  • Capped or uncapped supply
  • Burn functionality
  • Access control
Use cases: Inflationary tokens, dynamic supply management

🖼️ NFT Templates

ERC-721 NFTBasic NFT collection:
  • Unique token IDs
  • Metadata support
  • Enumerable extension
  • URI storage
Use cases: Art collections, gaming items, certificates
ERC-1155 Multi-TokenMulti-token standard:
  • Fungible + non-fungible in one contract
  • Batch operations
  • Gas efficient
  • URI per token type
Use cases: Gaming assets, mixed collections

💎 DeFi Templates

Staking ContractToken staking with rewards:
  • Stake/unstake tokens
  • Reward calculation
  • Time-based rewards
  • Emergency withdraw
Use cases: Yield farming, token locking
AMM Liquidity PoolUniswap V2-style pool:
  • Add/remove liquidity
  • Token swaps
  • LP token minting
  • Price oracle
Use cases: DEX liquidity, token trading

🏛️ DAO Templates

DAO GovernorGovernance with timelock:
  • Proposal creation
  • Voting mechanism
  • Timelock execution
  • Quorum requirements
Use cases: Protocol governance, community decisions

🛠️ Utility Templates

Multi-Signature WalletMulti-sig wallet:
  • Multiple owners
  • Threshold approvals
  • Transaction queuing
  • Owner management
Use cases: Treasury management, team wallets

Deployment Guide

Prerequisites

1

Install Dependencies

npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npm install @openzeppelin/contracts
2

Configure Hardhat

Get deployment config using deploy-config action
3

Set Environment Variables

export PRIVATE_KEY="your_private_key"
export CRONOSCAN_API_KEY="your_api_key"

Deployment Commands

# Deploy to testnet
npx hardhat run scripts/deploy.js --network cronos_testnet

# Deploy to mainnet
npx hardhat run scripts/deploy.js --network cronos_mainnet

# Verify contract
npx hardhat verify --network cronos_mainnet CONTRACT_ADDRESS "Constructor" "Args"

# Run tests
npx hardhat test

Interaction Examples

Read Functions

// Get token balance
const balance = await token.balanceOf(address);

// Get total supply
const supply = await token.totalSupply();

// Check allowance
const allowance = await token.allowance(owner, spender);

Write Functions

// Transfer tokens
await token.transfer(recipient, amount);

// Approve spender
await token.approve(spender, amount);

// Transfer from
await token.transferFrom(sender, recipient, amount);

Customization Tips

Modify Parameters

Adjust token name, symbol, supply, etc.

Add Features

Extend with additional functionality

Security

Add access controls and safety checks

Gas Optimization

Optimize for lower gas costs

Best Practices

Security Considerations
  • Always audit contracts before mainnet deployment
  • Use latest OpenZeppelin versions
  • Test thoroughly on testnet
  • Consider formal verification for high-value contracts
  • Implement emergency pause mechanisms
Development Tips
  • Use version control (Git)
  • Write comprehensive tests
  • Document your modifications
  • Keep dependencies updated
  • Use linters and formatters

query_cronos_sdk_docs

Find SDK examples for contract interaction

decode_transaction_error

Debug deployment and interaction issues