Developer Guide

Build with Mesh or extend it.

Project Structure

mesh-contracts/
├── Frontend/          # React app
├── relayer/           # Cross-chain service
├── evm_contracts/     # Ethereum contracts
├── sui_contracts/     # Sui contracts
└── docs/              # Documentation

Development Setup

1. Clone and install

git clone https://github.com/ashwanth511/mesh
cd mesh

# Frontend
cd Frontend && npm install

# Relayer
cd ../relayer && npm install

2. Install blockchain tools

# Foundry (Ethereum)
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Sui CLI
cargo install --git https://github.com/MystenLabs/sui.git sui

3. Set up environment

# Copy config files
cp relayer/env.example relayer/.env
cp Frontend/.env.example Frontend/.env

# Edit with your settings

Building and Testing

Frontend:

cd Frontend
npm run dev        # Start development server
npm run build      # Build for production
npm test           # Run tests

Contracts:

# Ethereum
cd evm_contracts
forge build        # Compile contracts
forge test         # Run tests

# Sui
cd sui_contracts
sui move build     # Compile contracts
sui move test      # Run tests

Relayer:

cd relayer
npm start          # Start relayer
npm test           # Run tests

Key Technologies

Frontend (React):

  • React 18 with TypeScript

  • Wagmi for Ethereum wallets

  • Sui SDK for Sui wallets

  • Vite for building

Ethereum (Solidity):

  • Foundry development framework

  • OpenZeppelin security libraries

  • 1inch Fusion+ integration

  • ethers.js for interaction

Sui (Move):

  • Move programming language

  • Sui SDK for JavaScript

  • Generic contract design

  • Capability-based security

Relayer (TypeScript):

  • Node.js backend service

  • Event-driven architecture

  • Cross-chain coordination

  • Secret management

Extending Mesh

Add new token pairs:

  1. Deploy contracts for new tokens

  2. Update relayer configuration

  3. Add token info to frontend

  4. Test with small amounts

Modify swap logic:

  1. Update smart contracts

  2. Deploy new versions

  3. Update relayer to handle changes

  4. Test thoroughly

Build integrations:

  1. Use Mesh contracts in your app

  2. Connect to relayer API

  3. Handle swap events

  4. Provide user interface

API Reference

Smart Contract Functions:

// Ethereum
function initiateSwap(params) external
function fillSwap(orderHash, secret) external
function cancelSwap(orderHash) external
// Sui
public fun initiate_atomic_swap<T>(...)
public fun execute_atomic_swap<T>(...)
public fun reclaim_atomic_swap<T>(...)

Relayer Events:

  • SwapCreated

  • SwapFilled

  • SwapCompleted

  • SwapCancelled

Best Practices

Security:

  • Always test on testnets first

  • Audit contract changes

  • Use secure key management

  • Monitor for unusual activity

Performance:

  • Optimize gas usage

  • Use efficient data structures

  • Implement proper error handling

  • Monitor system resources

UX:

  • Provide clear status updates

  • Handle errors gracefully

  • Make wallets easy to connect

  • Show realistic time estimates

Contributing

  1. Fork the repository

  2. Create feature branch

  3. Make your changes

  4. Add tests

  5. Submit pull request

Areas for contribution:

  • New blockchain integrations

  • UI/UX improvements

  • Gas optimization

  • Documentation

  • Testing coverage

Last updated