API Reference
Complete API documentation for @tetherto/wdk-wallet-solana
API Reference
Table of Contents
| Class | Description | Methods |
|---|---|---|
| WalletManagerSolana | Extends @tetherto/wdk-wallet. | Constructor, Methods, Properties |
| WalletAccountReadOnlySolana | Read-only Solana wallet account implementation. | Constructor, Methods, Properties |
| WalletAccountSolana | Full-featured Solana wallet account implementation with signing capabilities. | Methods, Properties |
WalletManagerSolana
Extends @tetherto/wdk-wallet
Constructor
new WalletManagerSolana(seed, config?)Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.config(SolanaWalletConfig, optional): The configuration object.
Source
src/wallet-manager-solana.js#L45
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
dispose() | Disposes all the wallet accounts, erasing their private keys from the memory. | void | - |
getAccount(index) | Returns the wallet account at a specific index (see SLIP-0010). | Promise<WalletAccountSolana> | - |
getAccountByPath(path) | Returns the wallet account at a specific SLIP-0010 derivation path. | Promise<WalletAccountSolana> | - |
getFeeRates() | Returns the current fee rates. | Promise<FeeRates> | - |
(static) getRandomSeedPhrase(wordCount) | Returns a random BIP-39 seed phrase. | string | - |
(static) isValidSeedPhrase(seedPhrase) | Checks if a seed phrase is valid. | boolean | - |
dispose()
Disposes all the wallet accounts, erasing their private keys from the memory.
Returns
void
getAccount(index)
Returns the wallet account at a specific index (see SLIP-0010).
Parameters
index(number, optional): The index of the account to get (default: 0).
Returns
Promise<WalletAccountSolana> - The account.
Example
// Returns the account with derivation path m/44'/501'/index'/0'
const account = await wallet.getAccount(1);Source
src/wallet-manager-solana.js#L98
getAccountByPath(path)
Returns the wallet account at a specific SLIP-0010 derivation path.
Parameters
path(string): The derivation path (e.g. "0'/0'/0'").
Returns
Promise<WalletAccountSolana> - The account.
Example
// Returns the account with derivation path m/44'/501'/0'/0'/1'
const account = await wallet.getAccountByPath("0'/0'/1'");Source
src/wallet-manager-solana.js#L111
getFeeRates()
Returns the current fee rates.
Returns
Promise<FeeRates> - The fee rates (in lamports).
Source
src/wallet-manager-solana.js#L126
getRandomSeedPhrase(wordCount) (static)
Returns a random BIP-39 seed phrase.
Parameters
wordCount(12 | unknown, optional): The number of words in the seed phrase.
Returns
string - The seed phrase.
isValidSeedPhrase(seedPhrase) (static)
Checks if a seed phrase is valid.
Parameters
seedPhrase(string): The seed phrase.
Returns
boolean - True if the seed phrase is valid.
Properties
| Property | Type | Description |
|---|---|---|
seed | Uint8Array | The seed phrase of the wallet. |
WalletAccountReadOnlySolana
Read-only Solana wallet account implementation.
Extends @tetherto/wdk-wallet
Constructor
new WalletAccountReadOnlySolana(addr, config?)Parameters
addr(string): The account's address.config(Omit<SolanaWalletConfig, "transferMaxFee">, optional): The configuration object.
Source
src/wallet-account-read-only-solana.js#L84
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_assertFeePayer(tx) | Asserts that any explicit transaction fee payer matches this wallet address. | Promise<void> | Yes |
_buildNativeTransferTransactionMessage(to, value) | Builds a transaction message for native SOL transfer. Creates a transfer instruction for sending SOL. | Promise<TransactionMessage> | - |
_buildSPLTransferTransactionMessage(token, recipient, amount) | Builds a transaction message for SPL token transfer. Creates instructions for ATA creation (if needed) and token transfer. | Promise<TransactionMessage> | - |
_ensureLifetime(tx) | Ensures the transaction has either a blockhash lifetime or a durable nonce lifetime. | Promise<SolanaTransaction> | - |
_getTransactionFee(transactionMessage) | Calculates the fee for a given transaction message. | Promise<bigint> | - |
getAddress() | Returns the account's address. | Promise<string> | - |
getBalance() | Returns the account's native SOL balance. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific SPL token. | Promise<bigint> | - |
getTokenBalances(tokenAddresses) | Returns the account balances for a list of SPL tokens. | Promise<Record<string, bigint>> | - |
getTransactionReceipt(hash) | Retrieves a transaction receipt by its signature | Promise<Readonly<object> & (Record<string, never> | { version: TransactionVersion; }) & { meta: Readonly<{ computeUnitsConsumed?: bigint; err: TransactionError; fee: Lamports; ... 7 more ...; status: TransactionStatus; }> & (Readonly<...> & (Record<...> | Readonly<...>)); transaction: Readonly<...> & (Readonly<...> & (Record<...> | Readonly<....> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options) | Quotes the costs of a transfer operation. | Promise<Omit<TransferResult, "hash">> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
_assertFeePayer(tx)
Asserts that any explicit transaction fee payer matches this wallet address.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<void> - Resolves when the transaction has no explicit fee payer or it matches this wallet address.
Throws
If the transaction fee payer does not match this wallet address.
Source
src/wallet-account-read-only-solana.js#L520
_buildNativeTransferTransactionMessage(to, value)
Builds a transaction message for native SOL transfer. Creates a transfer instruction for sending SOL.
Parameters
to(string): The recipient's address.value(number | bigint): The amount of SOL to send (in lamports).
Returns
Promise<TransactionMessage> - The constructed transaction message.
Source
src/wallet-account-read-only-solana.js#L419
_buildSPLTransferTransactionMessage(token, recipient, amount)
Builds a transaction message for SPL token transfer. Creates instructions for ATA creation (if needed) and token transfer.
Parameters
token(string): The SPL token mint address (base58-encoded public key).recipient(string): The recipient's wallet address (base58-encoded public key).amount(number | bigint): The amount to transfer in token's base units (must be ≤ 2^64-1).
Returns
Promise<TransactionMessage> - The constructed transaction message.
Source
src/wallet-account-read-only-solana.js#L339
_ensureLifetime(tx)
Ensures the transaction has either a blockhash lifetime or a durable nonce lifetime.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<SolanaTransaction> - The transaction with lifetime.
Source
src/wallet-account-read-only-solana.js#L500
_getTransactionFee(transactionMessage)
Calculates the fee for a given transaction message.
Parameters
transactionMessage(TransactionMessage): The transaction message to calculate fee for.
Returns
Promise<bigint> - The calculated transaction fee in lamports.
Source
src/wallet-account-read-only-solana.js#L452
getAddress()
Returns the account's address.
Returns
Promise<string> - The account's address.
getBalance()
Returns the account's native SOL balance.
Returns
Promise<bigint> - The sol balance (in lamports).
Source
src/wallet-account-read-only-solana.js#L134
getTokenBalance(tokenAddress)
Returns the account balance for a specific SPL token.
Parameters
tokenAddress(string): The smart contract address of the token.
Returns
Promise<bigint> - The token balance (in base unit).
Source
src/wallet-account-read-only-solana.js#L151
getTokenBalances(tokenAddresses)
Returns the account balances for a list of SPL tokens.
Parameters
tokenAddresses(string[]): The smart contract addresses of the tokens.
Returns
Promise<Record<string, bigint>> - A mapping of token addresses to their balances (in base units).
Source
src/wallet-account-read-only-solana.js#L185
getTransactionReceipt(hash)
Retrieves a transaction receipt by its signature
Parameters
hash(string): The transaction's hash.
Returns
Promise<Readonly<object> & (Record<string, never> | { version: TransactionVersion; }) & { meta: Readonly<{ computeUnitsConsumed?: bigint; err: TransactionError; fee: Lamports; ... 7 more ...; status: TransactionStatus; }> & (Readonly<...> & (Record<...> | Readonly<...>)); transaction: Readonly<...> & (Readonly<...> & (Record<...> | Readonly<....> - — The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-solana.js#L308
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-solana.js#L259
quoteTransfer(options)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash">> - The transfer's quotes.
Source
src/wallet-account-read-only-solana.js#L289
verify(message, signature)
Verifies a message's signature.
Parameters
message(string): The original message.signature(string): The signature to verify.
Returns
Promise<boolean> - True if the signature is valid.
Source
src/wallet-account-read-only-solana.js#L481
Properties
| Property | Type | Description |
|---|---|---|
_address | string | The account's address. |
WalletAccountSolana
Full-featured Solana wallet account implementation with signing capabilities.
Extends @tetherto/wdk-wallet-solana
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_assertFeePayer(tx) | Asserts that any explicit transaction fee payer matches this wallet address. | Promise<void> | Yes |
_buildNativeTransferTransactionMessage(to, value) | Builds a transaction message for native SOL transfer. Creates a transfer instruction for sending SOL. | Promise<TransactionMessage> | - |
_buildSPLTransferTransactionMessage(token, recipient, amount) | Builds a transaction message for SPL token transfer. Creates instructions for ATA creation (if needed) and token transfer. | Promise<TransactionMessage> | - |
_ensureLifetime(tx) | Ensures the transaction has either a blockhash lifetime or a durable nonce lifetime. | Promise<SolanaTransaction> | - |
_getTransactionFee(transactionMessage) | Calculates the fee for a given transaction message. | Promise<bigint> | - |
dispose() | Disposes the wallet account, erasing the private key from the memory. | void | - |
getAddress() | The address of this account. | Promise<string> | - |
getBalance() | Returns the account's native SOL balance. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific SPL token. | Promise<bigint> | - |
getTokenBalances(tokenAddresses) | Returns the account balances for a list of SPL tokens. | Promise<Record<string, bigint>> | - |
getTransactionReceipt(hash) | Retrieves a transaction receipt by its signature | Promise<Readonly<object> & (Record<string, never> | { version: TransactionVersion; }) & { meta: Readonly<{ computeUnitsConsumed?: bigint; err: TransactionError; fee: Lamports; ... 7 more ...; status: TransactionStatus; }> & (Readonly<...> & (Record<...> | Readonly<...>)); transaction: Readonly<...> & (Readonly<...> & (Record<...> | Readonly<....> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options) | Quotes the costs of a transfer operation. | Promise<Omit<TransferResult, "hash">> | - |
sendTransaction(tx) | Sends a transaction. | Promise<TransactionResult> | - |
sign(message) | Signs a message. | Promise<string> | - |
signTransaction(tx) | Signs a transaction. | Promise<FullySignedTransaction> | - |
toReadOnlyAccount() | Returns a read-only copy of the account. | Promise<WalletAccountReadOnlySolana> | - |
transfer(options) | Transfers a token to another address. | Promise<TransferResult> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
(static) at(seed, path, config) | Creates a new solana wallet account. | Promise<WalletAccountSolana> | - |
_assertFeePayer(tx)
Asserts that any explicit transaction fee payer matches this wallet address.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<void> - Resolves when the transaction has no explicit fee payer or it matches this wallet address.
Throws
If the transaction fee payer does not match this wallet address.
Source
src/wallet-account-read-only-solana.js#L520
_buildNativeTransferTransactionMessage(to, value)
Builds a transaction message for native SOL transfer. Creates a transfer instruction for sending SOL.
Parameters
to(string): The recipient's address.value(number | bigint): The amount of SOL to send (in lamports).
Returns
Promise<TransactionMessage> - The constructed transaction message.
Source
src/wallet-account-read-only-solana.js#L419
_buildSPLTransferTransactionMessage(token, recipient, amount)
Builds a transaction message for SPL token transfer. Creates instructions for ATA creation (if needed) and token transfer.
Parameters
token(string): The SPL token mint address (base58-encoded public key).recipient(string): The recipient's wallet address (base58-encoded public key).amount(number | bigint): The amount to transfer in token's base units (must be ≤ 2^64-1).
Returns
Promise<TransactionMessage> - The constructed transaction message.
Source
src/wallet-account-read-only-solana.js#L339
_ensureLifetime(tx)
Ensures the transaction has either a blockhash lifetime or a durable nonce lifetime.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<SolanaTransaction> - The transaction with lifetime.
Source
src/wallet-account-read-only-solana.js#L500
_getTransactionFee(transactionMessage)
Calculates the fee for a given transaction message.
Parameters
transactionMessage(TransactionMessage): The transaction message to calculate fee for.
Returns
Promise<bigint> - The calculated transaction fee in lamports.
Source
src/wallet-account-read-only-solana.js#L452
dispose()
Disposes the wallet account, erasing the private key from the memory.
Returns
void
Source
src/wallet-account-solana.js#L322
getAddress()
The address of this account.
Returns
Promise<string> - The address.
Source
src/wallet-account-solana.js#L188
getBalance()
Returns the account's native SOL balance.
Returns
Promise<bigint> - The sol balance (in lamports).
Source
src/wallet-account-read-only-solana.js#L134
getTokenBalance(tokenAddress)
Returns the account balance for a specific SPL token.
Parameters
tokenAddress(string): The smart contract address of the token.
Returns
Promise<bigint> - The token balance (in base unit).
Source
src/wallet-account-read-only-solana.js#L151
getTokenBalances(tokenAddresses)
Returns the account balances for a list of SPL tokens.
Parameters
tokenAddresses(string[]): The smart contract addresses of the tokens.
Returns
Promise<Record<string, bigint>> - A mapping of token addresses to their balances (in base units).
Source
src/wallet-account-read-only-solana.js#L185
getTransactionReceipt(hash)
Retrieves a transaction receipt by its signature
Parameters
hash(string): The transaction's hash.
Returns
Promise<Readonly<object> & (Record<string, never> | { version: TransactionVersion; }) & { meta: Readonly<{ computeUnitsConsumed?: bigint; err: TransactionError; fee: Lamports; ... 7 more ...; status: TransactionStatus; }> & (Readonly<...> & (Record<...> | Readonly<...>)); transaction: Readonly<...> & (Readonly<...> & (Record<...> | Readonly<....> - — The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-solana.js#L308
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-solana.js#L259
quoteTransfer(options)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash">> - The transfer's quotes.
Source
src/wallet-account-read-only-solana.js#L289
sendTransaction(tx)
Sends a transaction.
Parameters
tx(SolanaTransaction): The transaction.
Returns
Promise<TransactionResult> - The transaction's result.
Source
src/wallet-account-solana.js#L235
sign(message)
Signs a message.
Parameters
message(string): The message to sign.
Returns
Promise<string> - The message's signature.
Source
src/wallet-account-solana.js#L198
signTransaction(tx)
Signs a transaction.
Parameters
tx(SolanaTransaction): The transaction to sign.
Returns
Promise<FullySignedTransaction> - The signed transaction.
Source
src/wallet-account-solana.js#L215
toReadOnlyAccount()
Returns a read-only copy of the account.
Returns
Promise<WalletAccountReadOnlySolana> - The read-only account.
Source
src/wallet-account-solana.js#L310
transfer(options)
Transfers a token to another address.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<TransferResult> - The transfer's result.
Source
src/wallet-account-solana.js#L283
verify(message, signature)
Verifies a message's signature.
Parameters
message(string): The original message.signature(string): The signature to verify.
Returns
Promise<boolean> - True if the signature is valid.
Source
src/wallet-account-read-only-solana.js#L481
at(seed, path, config) (static)
Creates a new solana wallet account.
Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.path(string): The SLIP-0010 derivation path (e.g. "0'/0'/0'").config(SolanaWalletConfig, optional): The configuration object.
Returns
Promise<WalletAccountSolana> - The wallet account.
Source
src/wallet-account-solana.js#L134
Properties
| Property | Type | Description |
|---|---|---|
_address | string | The account's address. |
index | number | The derivation path's index of this account. |
keyPair | KeyPair | The account's key pair. Returns the raw key pair bytes in standard Solana format. - privateKey: 32-byte Ed25519 secret key (Uint8Array) - publicKey: 32-byte Ed25519 public key (Uint8Array) |
path | string | The derivation path of this account. |
Types
SimpleSolanaTransaction
| Property | Type | Description |
|---|---|---|
to | string | The recipient's Solana address. |
value | `number | bigint` |
Source
src/wallet-account-read-only-solana.js#L54
SolanaWalletConfig
| Property | Type | Description |
|---|---|---|
commitment? | Commitment | The commitment level (default: 'confirmed'). |
provider? | `string | string[]` |
retries? | number | If set and if 'provider' is a list of urls, the number of additional retry attempts after the initial call fails. Total attempts = 1 + retries. For example, retries: 3 with 4 providers will try each provider once before throwing. If retries exceeds the number of providers, the failover will loop back and retry already-failed providers in round-robin order (default: 3). |
rpcUrl? | `string | string[]` |
transferMaxFee? | `number | bigint` |