Skip to main content

Installing the Mach SDK

The Mach SDK provides easy access to the Mach Exchange functionality, allowing you to integrate cross-chain swaps, order management, and more into your application. It’s available on NPM and GitHub and can be used in both browsers and Node.js environments.

Installation

Using npm

npm install @tristeroresearch/mach-sdk

Using yarn

yarn add @tristeroresearch/mach-sdk

Dependencies

The Mach SDK uses viem for Ethereum interactions. If you don’t already have it in your project, you’ll need to install it:
npm install viem
# or with yarn
yarn add viem

SDK Structure

The SDK is organized into several key components:

Contracts

Contains interfaces for interacting with:
  • Mach platform contracts
  • ERC20 token contracts
  • Wrapped ETH contracts

Helpers

Utility functions for blockchain operations, including:
  • Creating wallet clients for blockchain interaction (createWalletClients)
  • Encoding order data for submission (encodeOrderData)
  • Market making operations (marketMakeOrder)
  • Chain and token utility functions (getChainFromName, dollarToTokenValue, getQuote)

Utils

Contains utility functions for the SDK, including:
  • Getting gas values for transactions

Constants

Provides easy access to:
  • Token addresses on each chain
  • Chain configurations
  • Contract addresses

Basic Import

After installation, you can import the SDK components like this:
// Import specific functions
import {
  createWalletClients,
  encodeOrderData,
  marketMakeOrder,
  getChainFromName,
  contracts,
  dollarToTokenValue,
  getQuote,
} from "@tristeroresearch/mach-sdk";

// Import constants
import { tokens, chains } from "@tristeroresearch/mach-sdk/constants";

Requirements

  • Node.js 16 or higher
  • TypeScript 4.5+ (recommended, but not required)
  • A browser environment or Node.js backend

Next Steps

Once you have installed the SDK, you can proceed to:

Troubleshooting

If you encounter issues during installation:
  1. Make sure your Node.js version is compatible
  2. Check for any conflicting dependencies
  3. If using TypeScript, ensure your tsconfig.json is properly configured
  4. Consult the GitHub repository for open issues