API Reference
API documentation for @tetherto/wdk-wallet-solana-gasless.
This page documents the published @tetherto/wdk-wallet-solana-gasless@1.0.0-beta.4 type declarations and runtime behavior.
Imports
import WalletManagerSolanaGasless from '@tetherto/wdk-wallet-solana-gasless'import {
WalletAccountReadOnlySolanaGasless,
WalletAccountSolanaGasless
} from '@tetherto/wdk-wallet-solana-gasless'Exports
| Export | Kind | Description |
|---|---|---|
WalletManagerSolanaGasless | Class, default export | Derives Solana gasless accounts from a seed. |
WalletAccountSolanaGasless | Class | Owned account with signing, sending, SPL transfer, quote, and read methods. |
WalletAccountReadOnlySolanaGasless | Class | Read-only account for balances, quotes, receipts, and signature verification. |
KeyPair | Type | Raw account key pair shape inherited from @tetherto/wdk-wallet. |
SolanaGaslessWalletConfig | Type | Solana wallet config plus required paymaster options. |
SolanaGaslessWalletPaymasterConfig | Type | Paymaster endpoint, address, and token configuration. |
SolanaGaslessWalletPaymasterConfigOverrides | Type | Per-call overrides for paymaster token and fee caps. |
PaymasterTokenConfig | Type | Paymaster fee token configuration. |
SolanaTransaction | Type | Simple Solana transaction input or transaction message input inherited from the Solana wallet module. |
SolanaTransactionReceipt | Type | Return type for getTransactionReceipt(). |
SolanaTransactionDetails | Type | Solana-specific fields on normalized transaction receipts. |
Finality, TransactionReceipt | Types | Shared normalized transaction status types. |
WaitForTransactionTarget, WaitForTransactionOptions | Types | Shared finality wait options. |
FullySignedTransaction | Type | Fully signed Solana transaction returned by signTransaction(). |
TransactionResult | Type | Result shape for send operations. |
TransferOptions | Type | SPL transfer input options. |
TransferResult | Type | Result shape for SPL token transfers. |
ConfigurationError | Type declaration only at the package root | The runtime uses this class internally but the beta.4 JavaScript root does not re-export it. |
WalletManagerSolanaGasless
Derives and returns owned Solana gasless accounts from a BIP-39 seed phrase or seed bytes. Extends WalletManager from @tetherto/wdk-wallet.
Constructor
new WalletManagerSolanaGasless(
seed: string | Uint8Array,
config?: SolanaGaslessWalletConfig
)Parameters:
seed: BIP-39 mnemonic seed phrase or seed bytes.config: Solana RPC and Kora-compatible paymaster configuration.
Methods
| Method | Description | Returns |
|---|---|---|
getAccount(index?) | Returns the account at the default Solana derivation path for the given index. | Promise<WalletAccountSolanaGasless> |
getAccountByPath(path) | Returns the account at a specific SLIP-0010 derivation path. | Promise<WalletAccountSolanaGasless> |
getAccount
getAccount(index?: number): Promise<WalletAccountSolanaGasless>Returns the account for m/44'/501'/index'/0'. If index is omitted, the module uses 0.
const wallet = new WalletManagerSolanaGasless(seedPhrase, config)
const account = await wallet.getAccount(0)getAccountByPath
getAccountByPath(path: string): Promise<WalletAccountSolanaGasless>Returns the account at a specific Solana SLIP-0010 derivation path.
const account = await wallet.getAccountByPath("0'/0'/1'")WalletAccountSolanaGasless
Owned Solana gasless account. Extends WalletAccountReadOnlySolanaGasless and implements IWalletAccount from @tetherto/wdk-wallet.
Constructor
new WalletAccountSolanaGasless(
seed: string | Uint8Array,
path: string,
config: SolanaGaslessWalletConfig
)Parameters:
seed: BIP-39 mnemonic seed phrase or seed bytes.path: SLIP-0010 derivation path, for example"0'/0'/0'".config: Solana RPC and Kora-compatible paymaster configuration.
Properties
| Property | Description | Type |
|---|---|---|
index | Derivation path index for this account. | number |
path | Derivation path for this account. | string |
keyPair | Raw Solana Ed25519 key pair bytes. | KeyPair |
Methods
| Method | Description | Returns |
|---|---|---|
getAddress() | Returns the account address. | Promise<string> |
sign(message) | Signs a message with the account private key. | Promise<string> |
verify(message, signature) | Verifies a message signature against the account address. | Promise<boolean> |
getBalance() | Returns the native SOL balance in lamports. | Promise<bigint> |
getTokenBalance(tokenAddress) | Returns one SPL token balance in base units. | Promise<bigint> |
getTokenBalances(tokenAddresses) | Returns multiple SPL token balances in base units. | Promise<Record<string, bigint>> |
getPaymasterTokenBalance() | Returns the configured paymaster token balance in base units. | Promise<bigint> |
quoteSendTransaction(tx, config?) | Quotes an unsigned send, or searches a fully signed transaction for a matching embedded payment fee. | Promise<Omit<TransactionResult, 'hash'>> |
signTransaction(tx, config?) | Returns a fully signed paymaster-funded transaction without broadcasting it. | Promise<FullySignedTransaction> |
sendTransaction(tx, config?) | Sends an unsigned paymaster-funded transaction, or directly broadcasts a fully signed transaction through Solana RPC. | Promise<TransactionResult> |
quoteTransfer(options, config?) | Quotes the paymaster fee for an SPL transfer. | Promise<Omit<TransferResult, 'hash'>> |
transfer(options, config?) | Transfers SPL tokens through the configured paymaster. | Promise<TransferResult> |
getTransactionReceipt(hash) | Reads a native Solana transaction; deprecated in favor of getTransaction(). | Promise<SolanaTransactionReceipt | null> |
getTransaction(hash) | Returns normalized finality for a Solana signature. | Promise<TransactionReceipt & SolanaTransactionDetails> |
waitForTransaction(hash, options?) | Waits for confirmed or final finality. | Promise<TransactionReceipt & SolanaTransactionDetails> |
toReadOnlyAccount() | Returns a read-only copy of the account. | Promise<WalletAccountReadOnlySolanaGasless> |
dispose() | Clears private key material held by the account. | void |
getAddress
getAddress(): Promise<string>Returns the account's base58-encoded Solana address.
sign
sign(message: string): Promise<string>Signs a message and returns its signature.
signTransaction
signTransaction(
tx: SolanaTransaction,
config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<FullySignedTransaction>Signs a paymaster-funded transaction without broadcasting it. The module adds the paymaster payment instruction, checks the quoted payment against transactionMaxFee, signs with the account owner, asks the paymaster to sign, and returns the fully signed transaction.
The method throws when the quoted paymaster fee is greater than transactionMaxFee.
sendTransaction
sendTransaction(
tx: SolanaTransaction | FullySignedTransaction,
config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<TransactionResult>For an unsigned input, sends a paymaster-funded native transfer or prebuilt transaction message. For the exact FullySignedTransaction returned by signTransaction(), the module does not contact the paymaster: it searches for the embedded payment fee, applies transactionMaxFee, base64-encodes the signed wire transaction, and sends it through the configured Solana RPC with encoding: 'base64'.
const result = await account.sendTransaction({
to: 'Recipient1111111111111111111111111111111',
value: 1000000n
}, {
transactionMaxFee: 500000n
})
console.log(result.hash)
console.log(result.fee)The method throws when the payment fee is greater than transactionMaxFee; a fee equal to the cap is allowed. An unsigned-flow payment above Number.MAX_SAFE_INTEGER can be rounded internally before this comparison. A signed transaction retains its existing blockhash or durable nonce lifetime, payment instruction, and signatures. The method does not refresh or re-sign it.
For arbitrary signed input, beta.4 returns fee: 0n when no matching payment instruction exists and can broadcast after that value passes the cap check. Restrict this path to exact output from the same account's signTransaction(), or independently validate the full signed message, payment, fee payer, lifetime, and signatures first.
transfer
transfer(
options: TransferOptions,
config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<TransferResult>Transfers SPL tokens through the paymaster. Native SOL transfers are handled by sendTransaction() instead.
const result = await account.transfer({
token: 'TokenMint111111111111111111111111111111111',
recipient: 'Recipient1111111111111111111111111111111',
amount: 1000000n
}, {
transferMaxFee: 500000n
})The method throws when the quoted paymaster fee is greater than transferMaxFee.
quoteSendTransaction
quoteSendTransaction(
tx: SolanaTransaction | FullySignedTransaction,
config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<Omit<TransactionResult, 'hash'>>For an unsigned input, requests a paymaster fee quote for sendTransaction() or signTransaction() inputs. Beta.4 validates the returned SPL payment instruction but converts its u64 amount through Number; values above Number.MAX_SAFE_INTEGER can round before being returned as bigint. For a FullySignedTransaction, it does not call the paymaster or broadcast: it searches for a signed SPL token payment to the configured paymaster token account and decodes a matching u64 exactly. If there is no match, beta.4 returns 0n rather than rejecting. Neither form enforces transactionMaxFee during the quote.
quoteTransfer
quoteTransfer(
options: TransferOptions,
config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<Omit<TransferResult, 'hash'>>Quotes the paymaster fee for transfer() inputs. Quote methods return estimates and do not enforce transferMaxFee.
getTransactionReceipt
getTransactionReceipt(hash: string): Promise<SolanaTransactionReceipt | null>Returns the native Solana transaction for a submitted signature, or null if it has not been included yet. This method is deprecated; use getTransaction() and read its transaction field for native data.
getTransaction
getTransaction(hash: string): Promise<TransactionReceipt & SolanaTransactionDetails>Returns normalized status for a valid base58 Solana signature. processed maps to pending, confirmed maps to confirmed, and finalized maps to final. Settled receipts expose success, the slot in block, the fee when available, confirmation count, and the native transaction when returned by the configured RPC commitment.
An invalid signature throws ValueError; a well-formed signature absent from transaction history throws NoSuchElementError.
waitForTransaction
waitForTransaction(
hash: string,
options?: WaitForTransactionOptions
): Promise<TransactionReceipt & SolanaTransactionDetails>Waits for the default confirmed target or for final when requested. The default polling interval is four seconds and timeout is 60 seconds. The Solana implementation does not currently emit dropped; a never-landed or evicted signature times out. Reaching the target does not prove successful execution, so inspect success.
toReadOnlyAccount
toReadOnlyAccount(): Promise<WalletAccountReadOnlySolanaGasless>Returns a read-only account for the same address.
WalletAccountReadOnlySolanaGasless
Read-only Solana gasless account for an address. Extends WalletAccountReadOnly from @tetherto/wdk-wallet.
Constructor
new WalletAccountReadOnlySolanaGasless(
addr: string,
config: Omit<SolanaGaslessWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>
)Parameters:
addr: Solana account address.config: Solana RPC and paymaster configuration. Read-only accounts do not accepttransferMaxFeeortransactionMaxFee.
Methods
| Method | Description | Returns |
|---|---|---|
getBalance() | Returns the native SOL balance in lamports. | Promise<bigint> |
getTokenBalance(tokenAddress) | Returns one SPL token balance in base units. | Promise<bigint> |
getTokenBalances(tokenAddresses) | Returns multiple SPL token balances in base units. | Promise<Record<string, bigint>> |
getPaymasterTokenBalance() | Returns the configured paymaster token balance in base units. | Promise<bigint> |
quoteSendTransaction(tx, config?) | Quotes the paymaster fee for a native send or transaction message. | Promise<Omit<TransactionResult, 'hash'>> |
quoteTransfer(options, config?) | Quotes the paymaster fee for an SPL transfer. | Promise<Omit<TransferResult, 'hash'>> |
getTransactionReceipt(hash) | Reads a native Solana transaction; deprecated in favor of getTransaction(). | Promise<SolanaTransactionReceipt | null> |
getTransaction(hash) | Returns normalized finality for a Solana signature. | Promise<TransactionReceipt & SolanaTransactionDetails> |
waitForTransaction(hash, options?) | Waits for confirmed or final finality. | Promise<TransactionReceipt & SolanaTransactionDetails> |
verify(message, signature) | Verifies a message signature against the account address. | Promise<boolean> |
Read-only and owned accounts have the same normalized transaction semantics. The package delegates these calls to the wrapped standard Solana read-only account.
Configuration Types
Normalized Transaction Types
type Finality = 'pending' | 'confirmed' | 'final' | 'dropped'
type WaitForTransactionTarget = 'confirmed' | 'final'
interface WaitForTransactionOptions {
target?: WaitForTransactionTarget
timeout?: number
interval?: number
maxPollErrors?: number
}
interface SolanaTransactionDetails {
confirmations: number | null
transaction: SolanaTransactionReceipt | null
}TransactionReceipt adds hash, finality, and optional success, block, and fee fields. These types are re-exported from the package root.
SolanaGaslessWalletConfig
type SolanaGaslessWalletConfig =
SolanaWalletConfig & SolanaGaslessWalletPaymasterConfigCombines the base Solana wallet configuration with the required paymaster configuration.
| Option | Type | Required | Description |
|---|---|---|---|
provider | string | string[] | No | Solana RPC endpoint or ordered failover list. RPC-backed reads, quotes, signing, sending, and transfers require a usable provider or rpcUrl. |
rpcUrl | string | string[] | No | Deprecated alias inherited from the base Solana wallet module. Use provider. |
commitment | 'processed' | 'confirmed' | 'finalized' | No | Solana commitment level for reads and receipts. |
retries | number | No | Additional retry attempts for ordered Solana RPC or paymaster failover lists. Default: 3. |
paymasterUrl | string | KoraClientOptions | Array<string | KoraClientOptions> | Yes | Kora-compatible paymaster endpoint, client options, or ordered failover list. |
paymasterAddress | string | Yes | Solana address used as the transaction fee payer. |
paymasterToken | PaymasterTokenConfig | Yes | Token used by the paymaster to quote and charge fees. |
transferMaxFee | number | bigint | No | Fee cap for transfer() calls, in the paymaster token's base units. |
transactionMaxFee | number | bigint | No | Fee cap for sendTransaction() and signTransaction() calls, in the paymaster token's base units. |
SolanaGaslessWalletPaymasterConfig
type SolanaGaslessWalletPaymasterConfig = {
paymasterUrl: string | KoraClientOptions | (string | KoraClientOptions)[]
paymasterAddress: string
paymasterToken: PaymasterTokenConfig
}PaymasterTokenConfig
type PaymasterTokenConfig = {
address: string
}SolanaGaslessWalletPaymasterConfigOverrides
type SolanaGaslessWalletPaymasterConfigOverrides = Partial<
Pick<SolanaGaslessWalletPaymasterConfig, 'paymasterToken'> &
Pick<SolanaWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>
>Pass overrides as the second argument to quote, sign, send, or transfer methods.
| Override | Applies to | Description |
|---|---|---|
paymasterToken | Quotes, signing, sends, transfers | Overrides the fee token for one call. |
transactionMaxFee | sendTransaction(), signTransaction() | Cancels the operation when the quoted transaction fee is above the cap. |
transferMaxFee | transfer() | Cancels the operation when the quoted transfer fee is above the cap. |
ConfigurationError
The beta.4 TypeScript declarations include ConfigurationError, and the runtime uses that error name for missing required paymaster fields. The JavaScript root entrypoint does not re-export the runtime class, so JavaScript code should not import ConfigurationError from @tetherto/wdk-wallet-solana-gasless.
class ConfigurationError extends Error {
constructor(message: string)
}Missing paymasterUrl, paymasterAddress, or paymasterToken throws an error named ConfigurationError. An empty paymasterUrl failover list throws a plain Error.
Next Steps
Configuration
Configure Solana RPC, paymaster endpoints, fee tokens, and fee caps.
Send Transactions
Quote, sign, and send paymaster-funded transactions.
Transfer SPL Tokens
Transfer SPL tokens through the paymaster.