@tetherto/wdk-wallet-solana
v1.0.0-beta.22
Published
Solana wallet module for WDK (Wallet Development Kit) by Tether.
Readme
@tetherto/wdk-wallet-solana
Note: This package is currently in beta. Please test thoroughly in development environments before using in production.
A Solana wallet module for WDK (Wallet Development Kit) by Tether. This package provides a clean API for creating, managing, and interacting with Solana wallets using BIP-39 seed phrases and Solana-specific derivation paths.
About WDK
This module is part of the WDK (Wallet Development Kit) project, which empowers developers to build secure, non-custodial wallets with unified blockchain access, stateless architecture, and complete user control.
For detailed documentation about the complete WDK ecosystem, visit docs.wdk.tether.io.
Installation
npm install @tetherto/wdk-wallet-solanaQuick Start
import WalletManagerSolana from '@tetherto/wdk-wallet-solana'
const seedPhrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
const wallet = new WalletManagerSolana(seedPhrase, {
provider: 'https://api.devnet.solana.com',
commitment: 'confirmed',
})
const account = await wallet.getAccount(0)
const address = await account.getAddress()
console.log('Address:', address)
wallet.dispose()The manager also accepts a signer in place of the seed phrase:
import { SeedSignerSolana } from '@tetherto/wdk-wallet-solana/signers'
const wallet = new WalletManagerSolana(new SeedSignerSolana(seedPhrase), {
provider: 'https://api.devnet.solana.com'
})Key Capabilities
- SLIP-0010 Derivation Paths: Standard Solana derivation support (
m/44'/501') - Multi-Account Management: Derive multiple accounts from a single seed phrase
- Native SOL Transactions: Quote and send SOL transfers through a unified wallet API
- SPL Token Support: Query balances and transfer SPL tokens, under both the classic Token Program and the Token Extensions Program (Token-2022)
- Transfer Memos: Attach a UTF-8 memo to a token transfer
- Message Signing: Sign messages and verify signatures with Solana accounts
- Fee Estimation: Retrieve current network fee rates and quote transaction costs
- Read-Only Accounts: Monitor any Solana address without a private key
- Secure Memory Disposal: Clear private keys from memory when done
Token-2022 Support
Balances and transfers work the same way for classic SPL tokens and Token-2022 tokens: the
wallet reads the mint to find which program owns it. A Token-2022 mint without extensions
behaves exactly like a classic one. For mints with extensions, transfer and quoteTransfer
apply the following rules.
| Extension | Behaviour |
| --- | --- |
| Transfer fee | Supported. amount is gross: the sender is debited amount and the recipient receives amount less the fee. quoteTransfer reports the fee as transferFee. |
| Interest-bearing | Supported. Balances are the raw amounts held, without accrued interest. |
| Required memo (on the recipient's account) | Supported. Pass { memo } as the second argument to transfer; without a memo, the token program rejects the transfer on chain. |
| Default account state: initialized | Supported. |
| Pausable | Supported. Transfers fail on chain while the mint is paused. |
| Non-transferable | Rejected with NonTransferableTokenError: the token cannot move at all. |
| Transfer hook | Supported when no hook program is set, since no hook runs. Rejected with TransferHookNotSupportedError when one is set: the wallet does not resolve the accounts a hook program needs. |
| Confidential transfer | Rejected with ConfidentialTransferNotSupportedError: the wallet does not perform confidential transfers. |
| Default account state: frozen | Supported between existing, thawed accounts. A transfer that would have to create the recipient's account is rejected with FrozenTokenAccountError, since the new account would be frozen and unable to receive. |
A transfer to a recipient whose token account is frozen is also rejected with
FrozenTokenAccountError. Other extensions need no special handling and are transferred
unchanged. All four errors are exported from the package.
quoteTransfer returns, next to the network fee:
rent: the lamports deposited to create the recipient's token account when it does not exist yet, or0n. A Token-2022 account is larger than a classic one, and larger again for a fee-bearing mint, so it costs more.transferFee: the token amount withheld by a fee-bearing mint, or0n.
const quote = await account.quoteTransfer({ token, recipient, amount: 1000000n }, { memo: 'invoice 42' })
// { fee: 5000n, rent: 2157600n, transferFee: 5000n }
await account.transfer({ token, recipient, amount: 1000000n }, { memo: 'invoice 42' })Compatibility
- Solana Mainnet Beta
- Solana Testnet
- Solana Devnet
- Standard Solana RPC Providers that support account, balance, and fee queries
Documentation
| Topic | Description | Link | |-------|-------------|------| | Overview | Module overview and feature summary | Wallet Solana Overview | | Usage | End-to-end integration walkthrough | Wallet Solana Usage | | Configuration | RPC, commitment, and transfer configuration | Wallet Solana Configuration | | API Reference | Complete class and type reference | Wallet Solana API Reference |
Examples
| Example | Description | |---------|-------------| | Create Wallet | Initialize a wallet manager and derive Solana accounts from a seed phrase | | Manage Accounts | Work with multiple accounts and custom SLIP-0010 derivation paths | | Check Balances | Query native SOL and SPL token balances for owned accounts | | Read-Only Account | Monitor balances for any Solana address without a private key | | Send Transaction | Estimate fees and send native SOL transactions | | Token Transfer | Transfer SPL tokens and estimate transfer fees | | Sign & Verify Message | Sign messages and verify signatures | | Fee Management | Retrieve current network fee rates | | Memory Management | Securely dispose wallets and clear private keys from memory |
For detailed walkthroughs, see the Usage Guide. See all runnable examples in the wdk-examples repository.
Community
Join the WDK Discord to connect with other developers.
Support
For support, please open an issue on GitHub or reach out via email.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
