WDK logoWDK documentation

API Reference

API documentation for @tetherto/wdk-wallet-solana-gasless.

This page documents the published @tetherto/wdk-wallet-solana-gasless@1.0.0-beta.1 type declarations.

Imports

Default import
import WalletManagerSolanaGasless from '@tetherto/wdk-wallet-solana-gasless'
Named imports
import {
  WalletAccountReadOnlySolanaGasless,
  WalletAccountSolanaGasless
} from '@tetherto/wdk-wallet-solana-gasless'

Exports

ExportKindDescription
WalletManagerSolanaGaslessClass, default exportDerives Solana gasless accounts from a seed.
WalletAccountSolanaGaslessClassOwned account with signing, sending, SPL transfer, quote, and read methods.
WalletAccountReadOnlySolanaGaslessClassRead-only account for balances, quotes, receipts, and signature verification.
KeyPairTypeRaw account key pair shape inherited from @tetherto/wdk-wallet.
SolanaGaslessWalletConfigTypeSolana wallet config plus required paymaster options.
SolanaGaslessWalletPaymasterConfigTypePaymaster endpoint, address, and token configuration.
SolanaGaslessWalletPaymasterConfigOverridesTypePer-call overrides for paymaster token and fee caps.
PaymasterTokenConfigTypePaymaster fee token configuration.
SolanaTransactionTypeSimple Solana transaction input or transaction message input inherited from the Solana wallet module.
SolanaTransactionReceiptTypeReturn type for getTransactionReceipt().
FullySignedTransactionTypeFully signed Solana transaction returned by signTransaction().
TransactionResultTypeResult shape for send operations.
TransferOptionsTypeSPL transfer input options.
TransferResultTypeResult shape for SPL token transfers.

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

MethodDescriptionReturns
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.

Get the first account
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.

Get an account by 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

PropertyDescriptionType
indexDerivation path index for this account.number
pathDerivation path for this account.string
keyPairRaw Solana Ed25519 key pair bytes.KeyPair

Methods

MethodDescriptionReturns
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 the paymaster fee for a native send or transaction message.Promise<Omit<TransactionResult, 'hash'>>
signTransaction(tx, config?)Returns a fully signed paymaster-funded transaction without broadcasting it.Promise<FullySignedTransaction>
sendTransaction(tx, config?)Sends a paymaster-funded native transfer or transaction message.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 Solana transaction receipt by signature.Promise<SolanaTransactionReceipt | null>
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 paymaster payment instructions, 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,
  config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<TransactionResult>

Sends a paymaster-funded native transfer or prebuilt transaction message.

Send native SOL
const result = await account.sendTransaction({
  to: 'Recipient1111111111111111111111111111111',
  value: 1000000n
}, {
  transactionMaxFee: 500000n
})

console.log(result.hash)
console.log(result.fee)

The method throws when the quoted paymaster fee is greater than transactionMaxFee.

transfer

transfer(
  options: TransferOptions,
  config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<TransferResult>

Transfers SPL tokens through the paymaster. Native SOL transfers are handled by sendTransaction() instead.

Transfer an SPL token
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,
  config?: SolanaGaslessWalletPaymasterConfigOverrides
): Promise<Omit<TransactionResult, 'hash'>>

Quotes the paymaster fee for sendTransaction() or signTransaction() inputs. Quote methods return estimates and do not enforce transactionMaxFee.

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 Solana transaction receipt for a submitted signature, or null if the transaction has not been included in a block yet.

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 accept transferMaxFee or transactionMaxFee.

Methods

MethodDescriptionReturns
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 Solana transaction receipt by signature.Promise<SolanaTransactionReceipt | null>
verify(message, signature)Verifies a message signature against the account address.Promise<boolean>

Configuration Types

SolanaGaslessWalletConfig

type SolanaGaslessWalletConfig =
  SolanaWalletConfig & SolanaGaslessWalletPaymasterConfig

Combines the base Solana wallet configuration with the required paymaster configuration.

OptionTypeRequiredDescription
providerstring | string[]NoSolana RPC endpoint or ordered failover list. RPC-backed reads, quotes, signing, sending, and transfers require a usable provider or rpcUrl.
rpcUrlstring | string[]NoDeprecated alias inherited from the base Solana wallet module. Use provider.
commitment'processed' | 'confirmed' | 'finalized'NoSolana commitment level for reads and receipts.
retriesnumberNoAdditional retry attempts for ordered Solana RPC or paymaster failover lists. Default: 3.
paymasterUrlstring | KoraClientOptions | Array<string | KoraClientOptions>YesKora-compatible paymaster endpoint, client options, or ordered failover list.
paymasterAddressstringYesSolana address used as the transaction fee payer.
paymasterTokenPaymasterTokenConfigYesToken used by the paymaster to quote and charge fees.
transferMaxFeenumber | bigintNoFee cap for transfer() calls, in the paymaster token's base units.
transactionMaxFeenumber | bigintNoFee 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.

OverrideApplies toDescription
paymasterTokenQuotes, signing, sends, transfersOverrides the fee token for one call.
transactionMaxFeesendTransaction(), signTransaction()Cancels the operation when the quoted transaction fee is above the cap.
transferMaxFeetransfer()Cancels the operation when the quoted transfer fee is above the cap.

ConfigurationError

The beta.1 TypeScript declarations include ConfigurationError, and the runtime uses that error name for missing required paymaster fields. The beta.1 JavaScript root entrypoint does not re-export the 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


Need Help?

On this page