For the complete documentation index, see llms.txt. This page is also available as Markdown.
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 functions, triggers, executions, and intents.
Getting Started
You can install Mimic Protocol's SDK by running the following command line:
yarnadd@mimicprotocol/sdk
Basic Client Initialization
import{Client}from'@mimicprotocol/sdk'// Basic client with default configurationconstclient=newClient()// Client with custom base URLconstclient=newClient({baseUrl:'https://api-protocol.mimic.fi'})
Client with Authentication
import{Client,ApiKeyAuth,BearerAuth}from'@mimicprotocol/sdk'// Using API key authenticationconstclient=newClient({auth:newApiKeyAuth('your-api-key')})// Using Bearer token authenticationconstclient=newClient({auth:newBearerAuth('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.
Functions
Manage WASM functions and their manifests.
Triggers
Manage function triggers and their lifecycle. Triggers define how and when functions should be executed.
Trigger deactivation supports batching. A single signature can deactivate multiple triggers as long as they belong to the same signer.
Trigger Config Types
Cron Trigger Config
Event Trigger Config
For example, if you want to track:
you should set topics to:
Once Trigger Config
You can also use createExecuteOnceTriggerConfig() to create an execute once trigger config.
Executions
Query function execution history and results. The list and detail endpoints return execution metadata, fee breakdown, and validations. Inputs, outputs, and logs are fetched separately through dedicated methods.
Intents
Query, encode, and decode intents and their operations. An intent contains one or more operations (intent.operations); each operation has an opType that identifies what it does.
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 ApiError instances 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.