npm.io
1.5.1 • Published 4d ago

@circle-fin/adapter-solana-kit

Licence
Version
1.5.1
Deps
11
Size
4.1 MB
Vulns
0
Weekly
308

Solana Kit Adapter

TypeScript License

Solana Adapter implementation powered by @solana/kit

Modern functional Solana integration for the App Kits ecosystem

Table of Contents

Overview

The Solana Kit Adapter is a strongly-typed implementation of the Adapter interface for the Solana blockchain. Built on top of the modern @solana/kit library (successor to @solana/web3.js), it provides type-safe, functional blockchain interactions through a unified interface designed to work seamlessly with the Bridge Kit for cross-chain USDC transfers between Solana and EVM networks, as well as any future kits for additional stablecoin operations.

Why Solana Kit Adapter?
  • @solana/kit Integration: Built using the modern, tree-shakeable @solana/kit library
  • Cross-Chain Ready: Designed for seamless integration with BridgeKit ecosystem
  • Type-Safe: Full TypeScript support with strict type checking
  • Functional APIs: Leverages @solana/kit's functional transaction building patterns
  • Multiple Signers: Support for private key and wallet provider signers
  • Tree-Shakeable: Optimized bundle sizes with selective imports
  • Action System: Comprehensive action handlers for token operations and CCTP
When and How Should I Use The Solana Kit Adapter?
I'm a developer using a kit

If you're using one of the kits to do some action, e.g. bridging from chain 'A' to chain 'B', then you only need to instantiate the adapter for your chain and pass it to the kit.

Example
const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
})

See the Quick Start section below for a more in depth guide on how to use the Solana Kit Adapter.

I'm a developer making a Kit Provider

If you are making a provider for other Kit users to plug in to the kit, e.g. a BridgingProvider, and you'll need to interact with different chains, then you'll need to use the abstracted Adapter methods to execute on chain.

Installation

npm install @circle-fin/adapter-solana-kit @solana/kit @solana/web3.js
# or
yarn add @circle-fin/adapter-solana-kit @solana/kit @solana/web3.js
Peer Dependencies

This adapter requires @solana/kit and @solana/web3.js as peer dependencies, allowing you to manage the versions yourself and avoid conflicts with your existing dependencies.

Required peer dependencies:

  • @solana/kit: ^5.0.0 (supports @solana/kit 5.0.0 through 5.x.x, excludes 6.x.x)
  • @solana/web3.js: ^1.98.2 (supports @solana/web3.js 1.98.2 through 1.x.x, excludes 2.x.x)

Installation:

# Install the adapter and all peer dependencies
npm install @circle-fin/adapter-solana-kit @solana/kit @solana/web3.js

# Or with yarn
yarn add @circle-fin/adapter-solana-kit @solana/kit @solana/web3.js

Version Compatibility:

Package Range Meaning
@solana/kit ^5.0.0 5.0.0 through 5.x.x
6.x.x and above (breaking changes)
@solana/web3.js ^1.98.2 1.98.2 through 1.x.x
2.x.x and above (breaking changes)

Benefits of Peer Dependencies:

  • Reduced bundle size: Avoids duplicate installations of Solana libraries
  • Version control: Use the versions that work best with your project
  • Conflict prevention: No version mismatches between adapter and your code
  • Flexibility: Upgrade independently when needed
  • Tree-shaking: @solana/kit's modular architecture benefits from a single installation

Note: The adapter uses inlined SPL Token helpers from @core/adapter-solana-base to avoid pulling in the deprecated @solana/spl-token package and its vulnerable bigint-buffer transitive dependency (GHSA-3gc7-fjrx-p6mg). Both listed peer dependencies (@solana/kit and @solana/web3.js) are used directly in the adapter's source code.

Troubleshooting Peer Dependencies
Missing Peer Dependency Warning

If you see warnings like:

npm WARN @circle-fin/adapter-solana-kit@x.x.x requires a peer of @solana/kit@^5.0.0 but none is installed.
npm WARN @circle-fin/adapter-solana-kit@x.x.x requires a peer of @solana/web3.js@^1.98.2 but none is installed.

Solution: Install all peer dependencies alongside the adapter:

npm install @solana/kit @solana/web3.js
Version Conflict

If you see errors about conflicting versions:

npm ERR! Could not resolve dependency:
npm ERR! peer @solana/kit@"^5.0.0" from @circle-fin/adapter-solana-kit
npm ERR! peer @solana/web3.js@"^1.98.2" from @circle-fin/adapter-solana-kit

Solution: Ensure your project uses compatible versions:

# Check your current versions
npm list @solana/kit @solana/web3.js

# Update to compatible versions if needed
npm install @solana/kit@^5.0.0 @solana/web3.js@^1.98.2
Choosing Between @solana/web3.js and @solana/kit

If you're unsure which Solana adapter to use:

  • Use @circle-fin/adapter-solana-kit if:

    • You want modern functional APIs
    • You need tree-shaking for smaller bundles
    • You're starting a new project
    • You want to leverage @solana/kit's modular architecture
  • Use @circle-fin/adapter-solana if:

    • You already use @solana/web3.js in your project
    • You need compatibility with existing web3.js code
    • You're migrating an existing project
Using Incompatible Versions

If you need to use newer major versions, the adapter may not work correctly:

For @solana/kit 6.x.x or @solana/web3.js 2.x.x:

  1. Stay on supported versions: Use versions within the supported ranges
    • @solana/kit: 5.0.0 - 5.x.x
    • @solana/web3.js: 1.98.2 - 1.x.x
  2. Check for updates: Look for newer adapter versions that support the newer library versions
  3. Report compatibility: Open an issue on the App Kits repository

For additional help, visit our Help Desk or Discord.

Quick Start

The simplest way to get started is with our factory methods. With reliable default RPC endpoints - no need to configure Solana RPC providers!

import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit'

// Create an adapter with built-in reliable RPC endpoints
const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!, // Base58, Base64, or JSON array format
})

// Ready to use with Stablecoin Kits!
const address = await adapter.getAddress()
console.log('Connected address:', address)

Key Feature: All Solana chains include reliable default RPC endpoints using @solana/kit's createSolanaRpc().

Production Considerations

Important for Production: The factory methods use public RPC endpoints by default when no custom RPC is provided, which may have rate limits and lower reliability. For production applications, we strongly recommend providing a custom RPC client.

import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit'
import { createSolanaRpc } from '@solana/kit'

// Production-ready setup with custom RPC endpoints
const customRpc = createSolanaRpc(
  `https://solana-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
)

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  getRpc: () => customRpc,
})
Browser Support with Wallet Providers

For browser environments with wallet providers like Phantom, Solflare, or Backpack:

import { createSolanaKitAdapterFromProvider } from '@circle-fin/adapter-solana-kit'

// Create an adapter from a browser wallet
const adapter = await createSolanaKitAdapterFromProvider({
  provider: window.solana, // Phantom, Solflare, etc.
})

Implementation Status: Fully Implemented

  • Connection Management: Complete RPC proxy and signer abstraction
  • Type Safety: Full TransactionSigner interface with native crypto APIs
  • Error Handling: Comprehensive validation and descriptive error messages
  • Wallet Integration: Complete transaction format conversion between @solana/kit and Wallet Standard

Recommendation: Use createSolanaKitAdapterFromPrivateKey() for server-side applications. Browser wallet integration follows Wallet Standard patterns.

Advanced Manual Setup

For advanced use cases requiring full control over RPC and signer:

import { SolanaKitAdapter } from '@circle-fin/adapter-solana-kit'
import { createSolanaRpc, generateKeyPairSigner } from '@solana/kit'

// Use your existing @solana/kit setup
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com')
const signer = await generateKeyPairSigner()

// Create the adapter
const adapter = new SolanaKitAdapter({
  rpc,
  signer,
})

Next-Generation API (/next)

Preview — The /next entrypoint is the upcoming default adapter architecture. It is at parity with the current entrypoint for the supported bridge flows and fully compatible with all existing kits (Bridge Kit, etc.). In the next major release, /next will become the default import and the current entrypoint will be retired. See Current limitations of /next before adopting it.

Getting Started with /next

Switch to the new architecture by changing a single import path. Everything else stays the same:

import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit/next'

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!, // Base58, Base64, or JSON array
})

// Pass it to the Bridge Kit exactly as before — no changes needed downstream

Browser wallets work identically:

import { createSolanaKitAdapterFromProvider } from '@circle-fin/adapter-solana-kit/next'

const adapter = await createSolanaKitAdapterFromProvider({
  provider: window.solana, // Phantom, Solflare, etc.
})
Why /next?
Current entrypoint /next entrypoint
Bundle size Entire adapter is included Per-primitive imports unlock tree-shaking; the default factory still pulls the compat shim — see bundle-size note
Prepare result estimate() and execute() estimate(), simulate(), and execute()
Fee model Adapter-specific shape { fee, units, unitPrice } — consistent across all ecosystems
Observability Not available Built-in logging, metrics, and event instrumentation
Retry & resilience Not available Configurable retry with exponential backoff for transient failures
Token resolution Hard-coded addresses Pluggable token registry — resolve any token by symbol across chains
Transaction tuning Fixed defaults Configurable confirmation timeout and retry policy
Bundle-size note

The /next entrypoint's clean architecture is designed to be tree-shakable on a per-primitive basis: importing createPrepare without createBatchExecute should only ship the prepare path. In the current preview release the default createAdapter factory still pulls in the legacy compat shim (withLegacyCompat@core/adapter-compat's action registry) so that consumers can pass the resulting adapter to existing kits and providers without changes. That shim is what makes the default /next bundle measure ~11% larger than the legacy entrypoint in our internal benchmarks.

If bundle size is critical to you, compose primitives directly via assembleAdapter from @core/adapter-base and skip withLegacyCompat. A future minor release will split the compat shim behind a separate entrypoint so the default factory ships the new API only.

Current limitations of /next

The /next Solana Kit adapter is at parity with the current entrypoint for the supported bridge flows, but a couple of caveats apply. They are tracked in the project issue tracker for follow-up releases:

  • The Circle Wallets adapter has not been migrated to /next. Only the EVM (viem/ethers) and Solana adapters expose a /next entrypoint; Circle Wallets remains on the current entrypoint.
  • Abort semantics stop the local wait only. Passing an aborted (or abortable) signal cancels waitForTransaction and prevents an unsent execute from broadcasting, but once a transaction has been broadcast, aborting does not cancel it on-chain — the transaction continues and should be reconciled via its signature.
Prepared Transactions: Estimate, Simulate, Execute

When you prepare a transaction through the /next adapter, you get back a richer object with three lifecycle methods:

const prepared = await adapter.prepare(
  {
    instructions: [transferInstruction],
    feePayer: payerPublicKey,
  },
  { chain: 'Solana' },
)

// 1. Estimate fees before committing
const { fee, units, unitPrice } = await prepared.estimate()

// 2. Simulate the transaction to catch errors without spending fees
const simulation = await prepared.simulate()

// 3. Execute when ready
const result = await prepared.execute()

// `result` is a `{ txId, wait }` envelope:
// - `txId` is the transaction signature (base58 string on Solana —
//   named `txId` for cross-ecosystem symmetry with the EVM adapters).
// - `wait()` resolves once the transaction is confirmed on the cluster.
console.log('submitted signature:', result.txId)
const confirmation = await result.wait()

The simulate() step is new in /next — it dry-runs the transaction against the current ledger state and surfaces errors before you pay transaction fees.

Logging

Pass a runtime option to get structured logs for every adapter operation, including RPC calls, retries, and errors. The quickest way to see what's happening is to use the built-in createRuntime helper:

import {
  createSolanaKitAdapterFromPrivateKey,
  createRuntime,
} from '@circle-fin/adapter-solana-kit/next'

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  runtime: createRuntime(), // Logs to stdout via pino at 'info' level
})

To integrate with your own logger, pass any object that implements debug, info, warn, error, and child to createRuntime. The logger interface uses (message, fields) argument order — libraries like pino use (fields, message), so a thin wrapper is needed:

import {
  createSolanaKitAdapterFromPrivateKey,
  createRuntime,
} from '@circle-fin/adapter-solana-kit/next'
import pino from 'pino'

function wrapPino(p: pino.Logger) {
  return {
    debug: (msg: string, fields?: Record<string, unknown>) =>
      p.debug(fields, msg),
    info: (msg: string, fields?: Record<string, unknown>) =>
      p.info(fields, msg),
    warn: (msg: string, fields?: Record<string, unknown>) =>
      p.warn(fields, msg),
    error: (msg: string, fields?: Record<string, unknown>) =>
      p.error(fields, msg),
    child: (tags: Record<string, unknown>) => wrapPino(p.child(tags)),
  }
}

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  runtime: createRuntime({ logger: wrapPino(pino({ level: 'debug' })) }),
})
Metrics

The runtime option also accepts a metrics implementation for counters, histograms, and timers. Plug into Prometheus, StatsD, Datadog, OpenTelemetry, or any other backend:

import {
  createSolanaKitAdapterFromPrivateKey,
  createRuntime,
} from '@circle-fin/adapter-solana-kit/next'

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  runtime: createRuntime({
    metrics: {
      counter: (name) => ({
        inc: (labels, value) => {
          /* emit counter */
        },
      }),
      histogram: (name) => ({
        observe: (labels, value) => {
          /* emit histogram */
        },
      }),
      timer: (name) => ({
        start: (labels) => {
          const t0 = Date.now()
          return () => {
            /* observe Date.now() - t0 */
          }
        },
      }),
      child: (labels) => {
        /* return scoped Metrics with base labels merged */
      },
    },
  }),
})

When no metrics is provided, metric calls are silently no-op'd — zero overhead.

Token Registry

By default the adapter knows about USDC (and other built-in tokens) on every supported chain. The tokens option lets you register additional tokens so they can be referenced by symbol instead of raw addresses.

import {
  createSolanaKitAdapterFromPrivateKey,
  createTokenRegistry,
} from '@circle-fin/adapter-solana-kit/next'

const tokens = createTokenRegistry({
  tokens: [
    {
      symbol: 'BONK',
      decimals: 5,
      locators: {
        Solana: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263',
      },
    },
  ],
})

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  tokens,
})

The registry resolves the correct program address and decimals for each chain automatically, so downstream code can refer to 'BONK' rather than hard-coding mint addresses.

Transaction Tuning

The config option lets you tune retry behavior and confirmation timeouts:

import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit/next'

const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
  config: {
    transaction: {
      confirmationTimeoutMs: 60_000, // 60 second confirmation timeout
    },
    retry: {
      maxAttempts: 5,
      baseDelayMs: 500,
    },
  },
})
Setting What it controls Default
confirmationTimeoutMs How long waitForTransaction waits before timing out Client default
retry.maxAttempts Maximum number of retry attempts (not including the initial attempt) 3
retry.baseDelayMs Base delay between retries in milliseconds (doubles on each retry via exponential backoff) 200

Set retry: false to disable automatic retries entirely.

Migration Path

The /next entrypoint is designed for a zero-friction migration:

  1. Today — Import from @circle-fin/adapter-solana-kit/next. The adapter returned is fully compatible with all existing kits and providers — no changes needed on their side.
  2. Next major release — The /next architecture becomes the default entrypoint (@circle-fin/adapter-solana-kit). The current class-based adapter will be removed.

What do I need to change?

  • Change the import path to @circle-fin/adapter-solana-kit/next.
  • The chain parameter has been removed from the factory. Chains are now resolved via capabilities.supportedChains (all Solana chains by default) and specified per-operation through OperationContext.
  • If you only pass the adapter to a kit, the kit handles chain selection automatically — no other changes needed.

Features

  • Full Solana compatibility - Works with Solana mainnet and devnet
  • @solana/kit integration - Uses modern functional APIs with tree-shaking support
  • Wallet provider support - Works with Phantom, Solflare, and other Solana wallets
  • Factory methods - Easy setup with sensible defaults
  • Transaction lifecycle - Complete prepare/estimate/execute workflow using @solana/kit patterns
  • Type safety - Full TypeScript support with strict mode
  • Cross-chain ready - Seamlessly bridge USDC between Solana and EVM chains

Usage Examples

Basic Usage with Factory Methods
import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit'
import { BridgeKit } from '@circle-fin/bridge-kit'

// Create adapter with factory method - supports multiple key formats!
const adapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!, // Accepts Base58, Base64, or JSON array
})

// Use directly with App Kit
const kit = new BridgeKit()
const result = await kit.bridge({
  from: { adapter: evmAdapter, chain: 'Base' },
  to: { adapter, chain: 'Solana' },
  amount: '10.50',
  token: 'USDC',
})
Multiple Private Key Format Support

The createSolanaKitAdapterFromPrivateKey function automatically detects and handles different private key formats:

// Base58 format (most common for Solana)
const adapterBase58 = createSolanaKitAdapterFromPrivateKey({
  privateKey: '5Kk7z8gvn...', // Base58 string
})

// Base64 format
const adapterBase64 = createSolanaKitAdapterFromPrivateKey({
  privateKey: 'MIGHAgEAMB...', // Base64 string
})

// JSON array format (array of bytes)
const adapterArray = createSolanaKitAdapterFromPrivateKey({
  privateKey: '[1,2,3,4,5,...]', // JSON array string
})
Cross-Chain Bridge (EVM → Solana)
import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit'
import { createViemAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
import { BridgeKit } from '@circle-fin/bridge-kit'

const kit = new BridgeKit()

// EVM source adapter
const evmAdapter = createViemAdapterFromPrivateKey({
  privateKey: process.env.EVM_PRIVATE_KEY as `0x${string}`,
})

// Solana destination adapter
const solanaAdapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
})

// Execute cross-chain bridge operation
const result = await kit.bridge({
  from: { adapter: evmAdapter, chain: 'Base_Sepolia' },
  to: { adapter: solanaAdapter, chain: 'Solana_Devnet' },
  amount: '10.50',
  token: 'USDC',
})
Browser Wallet Integration
import { createSolanaKitAdapterFromProvider } from '@circle-fin/adapter-solana-kit'
import { BridgeKit } from '@circle-fin/bridge-kit'

// Connect to user's Solana wallet
const adapter = await createSolanaKitAdapterFromProvider({
  provider: window.solana, // Phantom, Solflare, etc.
})

// Use with App Kit
const kit = new BridgeKit()
const result = await kit.bridge({
  from: { adapter: evmAdapter, chain: 'Base' },
  to: { adapter, chain: 'Solana' },
  amount: '50.0',
  token: 'USDC',
})
Manual Setup with @solana/kit Clients
import { SolanaKitAdapter } from '@circle-fin/adapter-solana-kit'
import { BridgeKit } from '@circle-fin/bridge-kit'
import { createSolanaRpc, generateKeyPairSigner } from '@solana/kit'

// Initialize with your @solana/kit setup
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com')
const signer = await generateKeyPairSigner()

const adapter = new SolanaKitAdapter({
  rpc,
  signer,
})

// Use directly with App Kit
const kit = new BridgeKit()
const result = await kit.bridge({
  from: { adapter: evmAdapter, chain: 'Ethereum' },
  to: { adapter, chain: 'Solana' },
  amount: '10.50',
  token: 'USDC',
})

Supported Networks

Works with all Solana networks supported by the App Kit:

  • Solana Mainnet - Production network
  • Solana Devnet - Development and testing network

API Reference

Factory Methods
createSolanaKitAdapterFromPrivateKey(options)

Create an adapter from a private key (supports multiple formats).

interface CreateAdapterFromPrivateKeyParams {
  privateKey: string // Supports Base58, Base64, or JSON array formats
  getRpc?: (params: { chain: ChainDefinition }) => Rpc<SolanaRpcApi> // Custom RPC factory
  capabilities?: AdapterCapabilities // Optional addressContext and supportedChains
}
createSolanaKitAdapterFromProvider(options)

Create an adapter from a Solana wallet provider.

interface CreateAdapterFromProviderParams {
  provider: SolanaKitWalletProvider // Phantom, Solflare, etc.
  getRpc?: (params: { chain: ChainDefinition }) => Rpc<SolanaRpcApi> // Custom RPC factory
  capabilities?: AdapterCapabilities // Optional addressContext and supportedChains
}
Constructor Options
interface SolanaKitAdapterOptions {
  getRpc: (params: {
    chain: ChainDefinition
  }) => Promise<Rpc<SolanaRpcApi>> | Rpc<SolanaRpcApi>
  getSigner: (
    ctx: OperationContext,
  ) => TransactionSigner | Promise<TransactionSigner>
}

Caching & Performance:

The adapter implements intelligent caching for both RPC clients and signers:

  • RPC Caching: RPC clients are cached per chain to prevent redundant initialization
  • Signer Caching: Signers are cached per operation context (based on chain and address) to avoid recreating signers for the same context
  • Concurrent Safety: Both caching mechanisms handle concurrent calls gracefully, preventing duplicate initialization

This ensures optimal performance when working with multiple chains or operation contexts.

Methods
  • getAddress() - Get the connected wallet address
  • getChain() - Get chain information
  • prepare() - Prepare transactions for execution using @solana/kit patterns
  • estimate() - Estimate transaction costs
  • execute() - Execute prepared transactions
  • waitForTransaction() - Wait for transaction confirmation
  • calculateTransactionFee() - Calculate transaction fees with optional buffer
Additional Exports

CCTP Integration:

  • CctpActionBuilder, SolanaAction - CCTP action interfaces
  • CoreCctpActionBuilder - Bridge between core CCTP logic and @solana/kit

Utilities:

  • convertInstruction, convertInstructions - Convert web3.js instructions to @solana/kit format

You can see the implementation of each method in the Solana Kit Adapter's main implementation file.

Architecture

Key Differences from @solana/web3.js

@solana/kit represents a complete architectural shift from class-based to functional programming patterns:

Category @solana/web3.js (Legacy) @solana/kit 3.0.2 (Modern) Migration Impact
RPC Client new Connection(rpcUrl) createSolanaRpc(rpcUrl) RPC proxy objects
Signers Keypair.fromSecretKey() generateKeyPairSigner() Native crypto APIs
Addresses new PublicKey(string) address(string) Branded type system
Transactions Transaction.add(ix) pipe(createTransactionMessage, append) Functional composition
Signing transaction.sign(signer) signTransactionMessageWithSigners(tx) Self-signing messages
Instructions TransactionInstruction Instruction with role metadata Enhanced account roles
Execution connection.sendTransaction() rpc.sendTransaction().send() Proxy method calls
Benefits of @solana/kit Architecture
  • Tree-shakeable: Complete library can be tree-shaken, drastically reducing bundle size
  • Native crypto: Leverages browser's built-in CryptoKeyPair and SubtleCrypto APIs
  • Immutable: Functional patterns with immutable transaction message building
  • Composable: Pipeline-based pipe() composition for transaction construction
  • Proxy-based: Dynamic RPC method construction keeps bundle size constant regardless of API coverage
Transaction Building Pattern
import {
  pipe,
  createTransactionMessage,
  setTransactionMessageFeePayerSigner,
  setTransactionMessageLifetimeUsingBlockhash,
  appendTransactionMessageInstruction,
  signTransactionMessageWithSigners,
} from '@solana/kit'

// Functional transaction building with immutable message construction
const transactionMessage = pipe(
  createTransactionMessage({ version: 0 }),
  (tx) => setTransactionMessageFeePayerSigner(signer, tx),
  (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
  (tx) => appendTransactionMessageInstruction(instruction, tx),
)

// Self-signing transaction messages
const signedTransaction =
  await signTransactionMessageWithSigners(transactionMessage)

// Send using RPC proxy
await rpc.sendTransaction(signedTransaction, { encoding: 'base64' }).send()

Integration with App Kit

This adapter is designed to work seamlessly across the App Kits ecosystem. Here's an example with the Bridge Kit:

import { BridgeKit } from '@circle-fin/bridge-kit'
import { createSolanaKitAdapterFromPrivateKey } from '@circle-fin/adapter-solana-kit'
import { createViemAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'

const kit = new BridgeKit()

// Solana adapter
const solanaAdapter = createSolanaKitAdapterFromPrivateKey({
  privateKey: process.env.SOLANA_PRIVATE_KEY!,
})

// EVM adapter
const evmAdapter = createViemAdapterFromPrivateKey({
  privateKey: process.env.EVM_PRIVATE_KEY as `0x${string}`,
})

// Bridge from EVM to Solana
const result = await kit.bridge({
  from: { adapter: evmAdapter, chain: 'Ethereum' },
  to: { adapter: solanaAdapter, chain: 'Solana' },
  amount: '50.0',
  token: 'USDC',
})

Development

This package is part of the App Kits monorepo.

# Build
nx build @circle-fin/adapter-solana-kit

# Test
nx test @circle-fin/adapter-solana-kit

License

This project is licensed under the Apache 2.0 License. Contact support for details.


Ready to integrate?

Join DiscordVisit our Help-Desk

Built with by Circle

Keywords