Skip to main content

Getting Started with Mach SDK

This quickstart guide will help you integrate Mach Protocol into your application and execute your first cross-chain swap.

Prerequisites

Before you begin, make sure you have:
  • Node.js 20+ installed
  • A project where you want to add cross-chain functionality
  • A private key for transaction signing (for testing purposes)

Installation

npm install @tristeroresearch/mach-sdk@latest

Basic Implementation

Here’s a minimal example to perform a cross-chain swap with the Mach SDK:
import { swapTokens } from '@tristeroresearch/mach-sdk';

// Function to perform a cross-chain swap
async function performCrossChainSwap() {
  try {
    const result = await swapTokens({
      fromChain: 'ethereum',    // Source chain
      toChain: 'arbitrum',      // Destination chain
      fromToken: 'USDC',        // Token to swap from
      toToken: 'USDC',          // Token to receive
      amount: '10',             // Amount to swap (in USDC)
      privateKey: process.env.PRIVATE_KEY // Your private key for transaction signing
    });
    
    console.log('Swap initiated:', result);
    return result;
  } catch (error) {
    console.error('Error performing swap:', error);
    throw error;
  }
}

Monitoring Your Swap

After initiating a swap, you can track its status:
import { getOrderStatus } from '@tristeroresearch/mach-sdk';

async function checkOrderStatus(orderId) {
  try {
    const status = await getOrderStatus(orderId);
    console.log('Order status:', status);
    return status;
  } catch (error) {
    console.error('Error checking order status:', error);
    throw error;
  }
}

Next Steps

SDK Installation

View detailed installation instructions

Integrating Mach

Learn about complete integration steps

Using Mach SDK

Explore advanced SDK features

Mach Architecture

Understand how Mach works under the hood

Sample Projects

To help you get started quickly, check out these sample implementations:
For support during integration, join our Discord community or reach out to our support team.