WDK logoWDK documentation

API Reference

Complete API documentation for @tetherto/wdk-wallet-solana

API Reference

Table of Contents

ClassDescriptionMethods
WalletManagerSolanaExtends @tetherto/wdk-wallet.Constructor, Methods, Properties
WalletAccountReadOnlySolanaRead-only Solana wallet account implementation.Constructor, Methods, Properties
WalletAccountSolanaFull-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

MethodDescriptionReturnsThrows
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

PropertyTypeDescription
seedUint8ArrayThe 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

MethodDescriptionReturnsThrows
_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 signaturePromise<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
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
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
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
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

PropertyTypeDescription
_addressstringThe account's address.

WalletAccountSolana

Full-featured Solana wallet account implementation with signing capabilities.

Extends @tetherto/wdk-wallet-solana

Methods

MethodDescriptionReturnsThrows
_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 signaturePromise<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
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
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
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
Returns

Promise<Omit<TransferResult, "hash">> - The transfer's quotes.

Source

src/wallet-account-read-only-solana.js#L289

sendTransaction(tx)

Sends a transaction.

Parameters
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
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
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

PropertyTypeDescription
_addressstringThe account's address.
indexnumberThe derivation path's index of this account.
keyPairKeyPairThe 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)
pathstringThe derivation path of this account.

Types

SimpleSolanaTransaction

PropertyTypeDescription
tostringThe recipient's Solana address.
value`numberbigint`
Source

src/wallet-account-read-only-solana.js#L54

SolanaWalletConfig

PropertyTypeDescription
commitment?CommitmentThe commitment level (default: 'confirmed').
provider?`stringstring[]`
retries?numberIf 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?`stringstring[]`
transferMaxFee?`numberbigint`
Source

src/wallet-account-read-only-solana.js#L64

On this page

Table of Contents
WalletManagerSolana
Constructor
Parameters
Source
Methods
dispose()
Returns
getAccount(index)
Parameters
Returns
Example
Source
getAccountByPath(path)
Parameters
Returns
Example
Source
getFeeRates()
Returns
Source
getRandomSeedPhrase(wordCount) (static)
Parameters
Returns
isValidSeedPhrase(seedPhrase) (static)
Parameters
Returns
Properties
WalletAccountReadOnlySolana
Constructor
Parameters
Source
Methods
_assertFeePayer(tx)
Parameters
Returns
Throws
Source
_buildNativeTransferTransactionMessage(to, value)
Parameters
Returns
Source
_buildSPLTransferTransactionMessage(token, recipient, amount)
Parameters
Returns
Source
_ensureLifetime(tx)
Parameters
Returns
Source
_getTransactionFee(transactionMessage)
Parameters
Returns
Source
getAddress()
Returns
getBalance()
Returns
Source
getTokenBalance(tokenAddress)
Parameters
Returns
Source
getTokenBalances(tokenAddresses)
Parameters
Returns
Source
getTransactionReceipt(hash)
Parameters
Returns
Source
quoteSendTransaction(tx)
Parameters
Returns
Source
quoteTransfer(options)
Parameters
Returns
Source
verify(message, signature)
Parameters
Returns
Source
Properties
WalletAccountSolana
Methods
_assertFeePayer(tx)
Parameters
Returns
Throws
Source
_buildNativeTransferTransactionMessage(to, value)
Parameters
Returns
Source
_buildSPLTransferTransactionMessage(token, recipient, amount)
Parameters
Returns
Source
_ensureLifetime(tx)
Parameters
Returns
Source
_getTransactionFee(transactionMessage)
Parameters
Returns
Source
dispose()
Returns
Source
getAddress()
Returns
Source
getBalance()
Returns
Source
getTokenBalance(tokenAddress)
Parameters
Returns
Source
getTokenBalances(tokenAddresses)
Parameters
Returns
Source
getTransactionReceipt(hash)
Parameters
Returns
Source
quoteSendTransaction(tx)
Parameters
Returns
Source
quoteTransfer(options)
Parameters
Returns
Source
sendTransaction(tx)
Parameters
Returns
Source
sign(message)
Parameters
Returns
Source
signTransaction(tx)
Parameters
Returns
Source
toReadOnlyAccount()
Returns
Source
transfer(options)
Parameters
Returns
Source
verify(message, signature)
Parameters
Returns
Source
at(seed, path, config) (static)
Parameters
Returns
Source
Properties
Types
SimpleSolanaTransaction
Source
SolanaWalletConfig
Source