Usage
Installation, quick start, and usage examples for @tetherto/wdk-wallet-solana
Installation
To install the @tetherto/wdk-wallet-solana package, follow these instructions:
npm install @tetherto/wdk-wallet-solanaQuick Start
Importing from @tetherto/wdk-wallet-solana
@tetherto/wdk-wallet-solanaWalletManagerSolana: Main class for managing wallets
WalletAccountSolana: Use this for full access accounts
WalletAccountReadOnlySolana: Use this for read-only accounts
Creating a New Wallet
import WalletManagerSolana, {
WalletAccountSolana,
WalletAccountReadOnlySolana
} from '@tetherto/wdk-wallet-solana'
// Use a BIP-39 seed phrase (replace with your own secure phrase)
const seedPhrase = 'your twelve word seed phrase here' // Replace with actual seed generation
// Create wallet manager with Solana RPC provider
const wallet = new WalletManagerSolana(seedPhrase, {
provider: 'https://api.mainnet-beta.solana.com', // or any Solana RPC endpoint
commitment: 'confirmed' // Optional: commitment level
})
// Get a full access account
const account = await wallet.getAccount(0)
// Convert to a read-only account
const readOnlyAccount = await account.toReadOnlyAccount()Managing Multiple Accounts
Checking Balances
Owned Account
For accounts where you have the seed phrase and full access:
Read-Only Account
For addresses where you don't have the seed phrase:
Sending Transactions
Send SOL and estimate fees using WalletAccountSolana. All transactions require a recent blockhash.
Token Transfers
Transfer SPL tokens and estimate fees using WalletAccountSolana. Uses Token Program instructions.
Message Signing and Verification
Sign and verify messages using Ed25519 cryptography.
Fee Management
Retrieve current fee rates using WalletManagerSolana. Rates are calculated based on recent blockhash and compute unit prices.
Memory Management
Clear sensitive data from memory using dispose methods in WalletAccountSolana and WalletManagerSolana.

