Skip to Content
Packages@tuwaio/orbit-solana@tuwaio/orbit-solana

@tuwaio/orbit-solana

NPM Version License

@tuwaio/orbit-solana is the Solana Layer 2 (L2) package of Orbit Utils, the Stage 1 primitives layer of the TUWA ecosystem. It is built on @solana/kit and the Wallet Standard (@wallet-standard/*), and provides cached RPC clients, wallet discovery, cluster and explorer helpers, and SNS name and avatar lookups. It does not use the legacy @solana/web3.js or gill.


🏛️ Core Capabilities

  • RPC clients: createSolanaClientWithCache returns a cached { rpc, rpcSubscriptions } pair (the WebSocket URL is derived from the HTTP URL); createSolanaRPC returns a cached rpc only. Both accept a full URL or a cluster moniker (mainnet, devnet, testnet, localnet).
  • Wallet Standard discovery: getAvailableSolanaConnectors lists installed wallets that support every feature Orbit relies on (standard:connect, standard:disconnect, standard:events, solana:signAndSendTransaction, solana:signTransaction, solana:signMessage) and only Solana chains. getConnectedSolanaConnector finds the wallet that holds the last connected address stored by @tuwaio/orbit-core.
  • Clusters and explorer links: getCluster, getRpcUrlForCluster, getSolanaClusters, getAvailableSolanaClusters, isValidSolanaCluster, isSolanaChainList, and getSolanaExplorerLink for Solana Explorer  URLs.
  • Names and avatars: getSolanaAddressName resolves an address to its favorite SNS (.sol) domain; getSolanaAddressAvatar returns the SNS profile image or a generated identicon. Both cache results in memory (clear…Cache, get…CacheSize, preloadSolanaAvatar).

Transactions are built and sent with @solana/kit itself, so any kit-compatible instruction builder works with the rpc returned here, including program clients generated by Codama .


💾 Installation

pnpm add @tuwaio/orbit-solana @tuwaio/orbit-core @solana/kit @wallet-standard/app @wallet-standard/ui-core @wallet-standard/ui-registry

[!IMPORTANT] @tuwaio/orbit-core (>=0.2), @solana/kit (>=8.2) and the @wallet-standard packages (1.x) are peer dependencies and must be installed alongside @tuwaio/orbit-solana.


🚀 Usage

Cached RPC client

import { address } from '@solana/kit'; import { createSolanaClientWithCache } from '@tuwaio/orbit-solana'; const { rpc } = createSolanaClientWithCache({ rpcUrlOrMoniker: 'devnet', rpcUrls: { devnet: 'https://devnet.my-rpc-provider.example' }, // optional; falls back to the public endpoint }); const { value: lamports } = await rpc.getBalance(address('So11111111111111111111111111111111111111112')).send();

Clients are cached by the rpcUrlOrMoniker string. localnet has no default URL, so pass it in rpcUrls. The public api.*.solana.com endpoints are rate-limited; use your own RPC provider in production.

Wallet discovery

import { getAvailableSolanaConnectors } from '@tuwaio/orbit-solana'; const wallets = getAvailableSolanaConnectors(); // UiWallet[] from @wallet-standard/ui-registry console.log(wallets.map((wallet) => wallet.name));
import { getSolanaAddressAvatar, getSolanaAddressName, getSolanaExplorerLink } from '@tuwaio/orbit-solana'; const owner = 'So11111111111111111111111111111111111111112'; const name = await getSolanaAddressName(owner); // "name.sol", or the address itself if no SNS domain is set const avatarUrl = await getSolanaAddressAvatar(name); getSolanaExplorerLink(`/address/${owner}`, 'solana:devnet'); // "https://explorer.solana.com/address/…?cluster=devnet"

🌐 External Services

Some helpers call public third-party HTTP services. The address or domain being looked up is sent to these hosts:

HelperHostPurpose
RPC clients (default URLs)api.mainnet-beta.solana.com, api.devnet.solana.com, api.testnet.solana.comPublic Solana RPC, used when no custom URL is configured
getSolanaAddressNamesns-api.bonfida.comFavorite SNS domain of an address
getSolanaAddressAvatarimage-api.bonfida.comSNS profile image of a .sol domain
getSolanaAddressAvatarapi.dicebear.comFallback identicon URL (loaded by the browser when rendered)

📚 API Reference

Every export, with signatures and types generated from the source, is documented at orbit.docs.tuwa.io/packages/orbit-solana .

📄 License

Licensed under the Apache-2.0 License. See the LICENSE  file for details.

Interfaces

Type Aliases

Functions

Last updated on