Typescript SDK
Comprehensive guide to using the MetaRouter TypeScript SDK for cross-chain token bridging.
MetaRouter TypeScript SDK
The MetaRouter TypeScript SDK provides a powerful and flexible interface for cross-chain token bridging and swaps. It leverages Caldera’s Metalayer and the MetaRouter API to offer seamless interoperability across multiple blockchain networks.
Features
- Cross-Chain Swaps and Bridges: Effortlessly swap tokens across different blockchain networks.
- Real-Time Price Quotes: Get accurate and up-to-date price quotes and gas estimates.
- WebSocket Streaming: Stream real-time price updates and transaction statuses.
- Type-Safe: Full TypeScript support ensures type safety and better developer experience.
- Middleware Support: Customize request and response handling with middleware.
- Multi-Network Support: Operate across various blockchain networks with ease.
Installation
To install the SDK, use your preferred package manager:
Quick Start
Here’s a quick guide to get you started with the MetaRouter SDK:
API Reference
MetaRouter
The main class for interacting with the SDK. It provides methods for obtaining quotes, executing swaps, and streaming data.
Configuration
Methods
static init(config: Partial<MetaRouterConfig>): MetaRouter
swap(params: ExecuteParams): Promise<ExecutionResult>
bridge(params: ExecuteParams): Promise<ExecutionResult>
quote(params: QuoteParams): Promise<RouteQuote>
Clients
The SDK provides specialized clients for different functionalities:
- RoutingClient: Handles route analysis and gas estimation.
- ExecutionClient: Manages transaction execution and approval checks.
- StreamingClient: Provides real-time data streams via WebSocket and provider subscriptions.
Error Handling
The SDK uses typed errors for better error handling. Ensure to catch and handle errors appropriately in your application.