SDK
The Mimic Protocol SDK provides a TypeScript client to interact with the Mimic Protocol blockchain automation platform. It offers a developer-friendly interface for managing tasks, configurations, executions, and intents.
Getting Started
You can install Mimic Protocol's SDK by running the following command line:
yarn add @mimicprotocol/sdkBasic Client Initialization
import { Client } from '@mimicprotocol/sdk'
// Basic client with default configuration
const client = new Client()
// Client with custom base URL
const client = new Client({
baseUrl: 'https://api-protocol.mimic.fi'
})Client with Authentication
import { Client, ApiKeyAuth, BearerAuth } from '@mimicprotocol/sdk'
// Using API key authentication
const client = new Client({
auth: new ApiKeyAuth('your-api-key')
})
// Using Bearer token authentication
const client = new Client({
auth: new BearerAuth('your-bearer-token')
})Client with Signer
Domain Clients
The SDK is organized into domain-specific clients, each handling a specific aspect of the protocol.
Balances
Query balance entries and compute totals.
Tasks
Manage WASM tasks and their manifests.
Configs
Manage task configurations and their lifecycle. Configs define how and when tasks should be executed.
Trigger Types
Cron Trigger
Event Trigger
Executions
Query task execution history and results. Each execution includes inputs (oracle responses), outputs (intents), fee breakdown, and validations.
Intents
Query, encode and decode intents and proposals associated to executions.
Error Handling
The SDK uses structured error handling with the ApiError class.
TypeScript Types
The SDK exports comprehensive TypeScript types for all data structures:
Configuration Options
Client Configuration
Per-Domain Configuration
Best Practices
Error Handling: Always wrap SDK calls in try-catch blocks and handle
ApiErrorinstances appropriately.Type Safety: Leverage TypeScript types for better development experience and compile-time error checking.
Configuration Management: Use environment variables for sensitive data like API keys and private keys.
Signer Management: In production, use secure signer implementations and never expose private keys in client-side code.
Last updated