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
Using yarn
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:Repository Links
- NPM: https://www.npmjs.com/package/@tristeroresearch/mach-sdk
- GitHub: https://github.com/tristeroresearch/mach-sdk
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: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:- Using the Mach SDK - Learn how to implement cross-chain swaps
- Integrating Mach - Full integration guide with examples
Troubleshooting
If you encounter issues during installation:- Make sure your Node.js version is compatible
- Check for any conflicting dependencies
- If using TypeScript, ensure your
tsconfig.jsonis properly configured - Consult the GitHub repository for open issues