Skip to main content

Standalone Functions

The Mina SDK exports all service functions as standalone imports. This allows you to use specific functionality without instantiating the full Mina client, which is useful for server-side code, custom caching strategies, or microservice architectures.

When to Use Standalone Functions

Server-Side Code

For API routes or serverless functions that only need specific features like fetching chains or tokens.

Custom Caching

When you need to implement your own caching layer or integrate with an external cache like Redis.

Microservices

For distributed systems where different services handle different parts of the bridge flow.

Tree Shaking

To minimize bundle size by importing only the functions you need.

Available Functions

Chain Functions

Token Functions

Balance Functions

Quote Functions

Execute Functions

Usage Examples

Fetching Chains

Fetching Tokens

Fetching Balances

Fetching Quotes

Using Custom Cache Instances

Standalone functions use a shared default cache. For isolation, pass your own cache instances:

Server-Side API Route Example

Microservice Architecture Example

Function Signatures

getChains

Returns all supported source chains with metadata.

getTokens

Returns all available tokens for a specific chain.

getBalance

Returns token balance with metadata.

getQuote

Returns optimal bridge quote.

execute

Executes a bridge transaction.
The execute function requires the full ExecuteConfig including the emitter for events. For most use cases, the Mina client’s execute method is simpler to use.

Best Practices

Cache Management

Create cache instances at the service/module level, not per-request, to benefit from caching.

Error Handling

Standalone functions throw the same typed errors as the client. Handle them appropriately.

Type Imports

Import types separately for cleaner code: import type { Chain, Token } from '@siphoyawe/mina-sdk'

Bundle Size

Import only what you need to minimize bundle size in browser environments.

Comparison: Client vs Standalone

Choose the Mina client for frontend applications and full-featured integrations. Use standalone functions for server-side code, microservices, or when you need fine-grained control over caching and configuration.