Client SDK
Overview
The JavaScript/TypeScript SDK provides a type-safe client library for interacting with Solana RWA programs. The SDK includes generated functions for fetching account data, building instructions, and managing all four RWA programs.
Installation
npm install @upsideos/solana-rwa
Programs
The SDK package includes clients for the following programs:
- Access Control - Manage wallet roles, permissions, and security token operations
- Transfer Restrictions - Enforce transfer rules between holder groups
- Tokenlock - Create and manage time-locked token releases
- Dividends - Distribute and claim dividends via merkle proofs
Usage
Fetching Account Data
The SDK provides generated functions for fetching account data from the Solana blockchain.
import { createSolanaRpc } from '@solana/kit';
import {
fetchAccessControl,
fetchMaybeWalletRole
} from '@upsideos/solana-rwa';
// Create RPC connection
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
// Compute PDA for access control account
const accessControlPda = '59mfBZPtvb64bVzXQHi8kLQoA2BmcuCD8GGa6rTKwbiM'; // Example PDA
// Fetch and decode access control account
const accessControl = await fetchAccessControl(rpc, accessControlPda);
// Access account data
console.log('Mint:', accessControl.data.mint);
console.log('Authority:', accessControl.data.authority);
console.log('Max Total Supply:', accessControl.data.maxTotalSupply);
// Fetch wallet role (returns MaybeAccount - check exists property)
const walletRolePda = '6ZNDXHtDQpG7Nz8po5otoXrPmCiMAMxsVLAr8Nc6XL95'; // Example PDA
const walletRole = await fetchMaybeWalletRole(rpc, walletRolePda);
if (walletRole.exists) {
console.log('Wallet Role:', walletRole.data.role);
}
Building Instructions
The SDK provides generated functions for building Solana instructions.
import { address } from '@solana/kit';
import {
getSetAddressPermissionInstructionAsync
} from '@upsideos/solana-rwa';
// Build a set address permission instruction
const setAddressPermissionInstruction = await getSetAddressPermissionInstructionAsync(
{
securityAssociatedAccount: securityAssociatedAccountAddress,
transferRestrictionGroupNew: groupNewAddress,
transferRestrictionGroupCurrent: groupCurrentAddress,
transferRestrictionHolder: transferRestrictionHolderAddress,
holderGroupNew: holderGroupNewAddress,
holderGroupCurrent: holderGroupCurrentAddress,
securityToken: mint,
userWallet: walletAddress,
userAssociatedTokenAccount: walletAssociatedAccountAddress,
authorityWalletRole: authorityWalletRoleAddress,
securityMint: mint,
accessControlAccount: accessControlHelper.accessControlPubkey!,
accessControlProgram: ACCESS_CONTROL_PROGRAM_ID,
payer: payerSigner,
authority: authoritySigner,
groupId: BigInt(groupId),
frozen,
},
{ programAddress: TRANSFER_RESTRICTIONS_PROGRAM_ID },
);