@tuwaio/orbit-solana
@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:
createSolanaClientWithCachereturns a cached{ rpc, rpcSubscriptions }pair (the WebSocket URL is derived from the HTTP URL);createSolanaRPCreturns a cachedrpconly. Both accept a full URL or a cluster moniker (mainnet,devnet,testnet,localnet). - Wallet Standard discovery:
getAvailableSolanaConnectorslists 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.getConnectedSolanaConnectorfinds the wallet that holds the last connected address stored by@tuwaio/orbit-core. - Clusters and explorer links:
getCluster,getRpcUrlForCluster,getSolanaClusters,getAvailableSolanaClusters,isValidSolanaCluster,isSolanaChainList, andgetSolanaExplorerLinkfor Solana Explorer URLs. - Names and avatars:
getSolanaAddressNameresolves an address to its favorite SNS (.sol) domain;getSolanaAddressAvatarreturns 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-standardpackages (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));Names, avatars and explorer links
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:
| Helper | Host | Purpose |
|---|---|---|
| RPC clients (default URLs) | api.mainnet-beta.solana.com, api.devnet.solana.com, api.testnet.solana.com | Public Solana RPC, used when no custom URL is configured |
getSolanaAddressName | sns-api.bonfida.com | Favorite SNS domain of an address |
getSolanaAddressAvatar | image-api.bonfida.com | SNS profile image of a .sol domain |
getSolanaAddressAvatar | api.dicebear.com | Fallback 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
- clearSolanaAvatarCache
- clearSolanaNameCache
- createSolanaClientWithCache
- createSolanaRPC
- getAvailableSolanaClusters
- getAvailableSolanaConnectors
- getCluster
- getConnectedSolanaConnector
- getRpcUrlForCluster
- getSolanaAddressAvatar
- getSolanaAddressName
- getSolanaAvatarCacheSize
- getSolanaClusters
- getSolanaExplorerLink
- getSolanaNameCacheSize
- isSolanaChainList
- isValidSolanaCluster
- preloadSolanaAvatar