Smart Contracts

The code that makes Mesh work.

Ethereum Contracts

SuiResolver - Main contract

  • Integrates with 1inch Fusion+

  • Handles ETH → SUI swaps

  • Manages secrets and timeouts

EscrowFactory - Creates escrows

  • Makes new contracts for each swap

  • Tracks all active swaps

  • Handles cleanup

EscrowSrc/EscrowDst - Hold tokens

  • Lock tokens safely during swaps

  • Release when conditions are met

  • Return money if swap fails

Sui Contracts

cross_chain_escrow - Main contract

  • Handles SUI → ETH swaps

  • Written in Move language

  • Supports any Sui token

hash_lock - Password system

  • Creates secret passwords

  • Validates passwords match

  • Prevents reuse

time_lock - Time limits

  • Sets deadlines for swaps

  • Returns money if expired

  • Uses Sui blockchain time

How They Work Together

  1. User creates swap on one chain

  2. Contracts lock tokens safely

  3. Relayer coordinates between chains

  4. Secret unlocks both sides at once

  5. Everyone gets their tokens

Security Features

Atomic swaps - Either both complete or both fail Time limits - Money returned if too slow Secret protection - Can't steal or reuse secrets No middleman - Contracts handle everything

For Developers

Ethereum contracts use:

  • Solidity programming language

  • OpenZeppelin security libraries

  • 1inch Fusion+ integration

  • Standard ERC-20 tokens

Sui contracts use:

  • Move programming language

  • Generic types (works with any token)

  • Sui standard library

  • Capability-based security

To deploy:

# Ethereum
cd evm_contracts
forge script script/Deploy.s.sol --broadcast

# Sui
cd sui_contracts
sui move publish

Contract Addresses

After deployment, you'll get addresses like:

  • Ethereum: 0x123... (on Sepolia testnet)

  • Sui: 0xabc... (package ID on testnet)

Update these in your config files to connect everything.

Last updated