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:
Deploy contracts for new tokens
Update relayer configuration
Add token info to frontend
Test with small amounts
Modify swap logic:
Update smart contracts
Deploy new versions
Update relayer to handle changes
Test thoroughly
Build integrations:
Use Mesh contracts in your app
Connect to relayer API
Handle swap events
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
Fork the repository
Create feature branch
Make your changes
Add tests
Submit pull request
Areas for contribution:
New blockchain integrations
UI/UX improvements
Gas optimization
Documentation
Testing coverage
Last updated