Mezod Chain Client Development Guide
Mezod is the reference client implementation for the Mezo chain, a Bitcoin-first blockchain designed for user ownership, reliable bridging with tBTC, BTC for gas, dual staking model, and EVM compatibility.
Overview
Section titled “Overview”Mezo is a Cosmos SDK-based chain with EVM compatibility running on top of Comet BFT consensus engine. The Mezod client codebase was forked from the LGPL version of Evmos and heavily modified for Mezo’s specific requirements.
Key Features
Section titled “Key Features”- Bitcoin-first Design: Native BTC integration and gas payments
- EVM Compatibility: Full Ethereum Virtual Machine support
- tBTC Bridging: Reliable cross-chain Bitcoin transfers
- Dual Staking Model: Rewards and validation mechanisms
- User Ownership: Decentralized governance and control
Repository Structure
Section titled “Repository Structure”The Mezod repository contains:
- Go Modules: Core blockchain client implementation
- x/ modules: Custom Cosmos SDK modules
- EVM Integration: Ethereum compatibility layer
- Configuration: Chain configuration and parameters
Development Setup
Section titled “Development Setup”Prerequisites
Section titled “Prerequisites”- Go 1.21+ (check
go.modfor exact version) - Git
- Make
- Docker (optional, for containerized development)
Installation
Section titled “Installation”-
Clone the repository:
Terminal window git clone https://github.com/mezo-org/mezod.gitcd mezod -
Install Go dependencies:
Terminal window go mod download -
Build the client:
Terminal window make build
Development Environment
Section titled “Development Environment”-
Local Development:
Terminal window # Start local development nodemake dev# Run testsmake test# Lint codemake lint -
Docker Development:
Terminal window # Build Docker imagedocker build -t mezod .# Run containerized nodedocker run -p 26657:26657 -p 8545:8545 mezod
Chain Configuration
Section titled “Chain Configuration”Network Parameters
Section titled “Network Parameters”Mezod supports multiple network configurations:
- Mainnet: Production Mezo network
- Testnet: Public testing network
- Local: Development network
Configuration Files
Section titled “Configuration Files”Key configuration files:
config.toml: Node configurationapp.toml: Application-specific settingsclient.toml: Client configuration
Example configuration:
[consensus]timeout_commit = "1s"timeout_propose = "3s"
[p2p]laddr = "tcp://0.0.0.0:26656"external_address = "YOUR_EXTERNAL_IP:26656"persistent_peers = "peer1@ip1:26656,peer2@ip2:26656"
[api]enable = trueaddress = "tcp://0.0.0.0:1317"EVM Integration
Section titled “EVM Integration”Ethereum Compatibility
Section titled “Ethereum Compatibility”Mezod provides full EVM compatibility, allowing you to:
- Deploy Ethereum smart contracts
- Use Ethereum tooling (Hardhat, Truffle, etc.)
- Interact with contracts using Web3 libraries
Connecting via Web3
Section titled “Connecting via Web3”import { ethers } from 'ethers';
// Connect to Mezo networkconst provider = new ethers.JsonRpcProvider('https://rpc.mezo.org');
// Get network infoconst network = await provider.getNetwork();console.log('Network:', network);
// Deploy contractconst factory = new ethers.ContractFactory(abi, bytecode, signer);const contract = await factory.deploy();await contract.waitForDeployment();Gas and Fees
Section titled “Gas and Fees”- BTC for Gas: Pay transaction fees in Bitcoin
- Dynamic Pricing: Gas prices adjust based on network conditions
- EVM Gas Model: Compatible with Ethereum gas calculations
Node Types
Section titled “Node Types”Full Node
Section titled “Full Node”A complete node that stores the entire blockchain:
# Start full nodemezod startLight Client
Section titled “Light Client”A lightweight client for mobile and resource-constrained environments:
# Start light clientmezod start --mode lightArchive Node
Section titled “Archive Node”A node that stores all historical data:
# Start archive nodemezod start --mode archiveRPC Endpoints
Section titled “RPC Endpoints”Cosmos SDK RPC
Section titled “Cosmos SDK RPC”- Port: 26657
- Endpoints: Standard Cosmos SDK RPC methods
- WebSocket: Real-time updates
# Query node statuscurl http://localhost:26657/statusEVM RPC
Section titled “EVM RPC”- Port: 8545
- Endpoints: Ethereum-compatible JSON-RPC
- Methods: eth_getBalance, eth_sendTransaction, etc.
# Query EVM balancecurl -X POST -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x...", "latest"],"id":1}' \ http://localhost:8545Development Workflow
Section titled “Development Workflow”Building Contracts
Section titled “Building Contracts”-
Write Solidity Contracts: Use standard Ethereum tooling
-
Compile: Use Hardhat, Truffle, or solc directly
-
Deploy: Deploy to Mezo testnet/mainnet
-
Interact: Use Web3 libraries or direct RPC calls
Testing
Section titled “Testing”# Run unit testsmake test
# Run integration testsmake test-integration
# Run specific test packagego test ./x/evm/...Integration Examples
Section titled “Integration Examples”Cosmos SDK Integration
Section titled “Cosmos SDK Integration”package main
import ( "context" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx")
func main() { // Create client context clientCtx := client.Context{}
// Create transaction builder txBuilder := clientCtx.TxConfig.NewTxBuilder()
// Build and send transaction // ... transaction logic}Monitoring and Debugging
Section titled “Monitoring and Debugging”Logging
Section titled “Logging”# Enable debug loggingmezod start --log-level debug
# Log to filemezod start --log-file /path/to/logfileMetrics
Section titled “Metrics”- Prometheus: Built-in metrics collection on port 26660
- Grafana: Dashboard for monitoring
- Health Checks: HTTP endpoints for health monitoring
# Check metricscurl http://localhost:26660/metricsDeployment
Section titled “Deployment”Production Deployment
Section titled “Production Deployment”Hardware Requirements:
- Minimum: 8GB RAM, 100GB SSD
- Recommended: 16GB RAM, 500GB NVMe SSD
Steps:
-
Configure firewall and network ports
-
Set up proper access controls
-
Deploy monitoring stack
-
Start node with production config
Docker Deployment
Section titled “Docker Deployment”# Production Docker deploymentdocker run -d \ --name mezod \ -p 26657:26657 \ -p 8545:8545 \ -v /data:/root/.mezod \ mezod:latest startTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”- Connection Issues: Check RPC endpoints and network connectivity
- Sync Problems: Verify blockchain synchronization
- Gas Issues: Monitor gas prices and adjust accordingly
Debug Commands
Section titled “Debug Commands”# Check node statusmezod status
# View logsmezod logs
# Reset node (caution: deletes data)mezod unsafe-reset-allAdditional Resources
Section titled “Additional Resources”- Mezod Repository - Main repository
- Mezo Documentation - Complete documentation
- Cosmos SDK Documentation - Cosmos SDK reference
- EVM Documentation - EVM specification
- Testnet Guide - Testnet access and usage
Support
Section titled “Support”For development support:
- Join the Mezo Discord
- Check the GitHub Issues
- Review the FAQ