API Reference
Complete API documentation for @tetherto/wdk-wallet-ton-gasless
API Reference
Table of Contents
| Class | Description | Methods |
|---|---|---|
| WalletManagerTonGasless | Extends @tetherto/wdk-wallet. | Constructor, Methods, Properties |
| WalletAccountReadOnlyTonGasless | Extends @tetherto/wdk-wallet. | Constructor, Methods, Properties |
| WalletAccountTonGasless | Extends @tetherto/wdk-wallet-ton-gasless. | Constructor, Methods, Properties |
WalletManagerTonGasless
Extends @tetherto/wdk-wallet
Constructor
new WalletManagerTonGasless(seed, config)Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.config(TonGaslessWalletConfig): The configuration object.
Source
src/wallet-manager-ton-gasless.js#L34
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 BIP-44). | Promise<WalletAccountTonGasless> | - |
getAccountByPath(path) | Returns the wallet account at a specific BIP-44 derivation path. | Promise<WalletAccountTonGasless> | - |
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 BIP-44).
Parameters
index(number, optional): The index of the account to get (default: 0).
Returns
Promise<WalletAccountTonGasless> - The account.
Example
// Returns the account with derivation path m/44'/607'/index'
const account = await wallet.getAccount(1);Source
src/wallet-manager-ton-gasless.js#L55
getAccountByPath(path)
Returns the wallet account at a specific BIP-44 derivation path.
Parameters
path(string): The derivation path (e.g. "0'/0/0").
Returns
Promise<WalletAccountTonGasless> - The account.
Example
// Returns the account with derivation path m/44'/607'/0'/0/1
const account = await wallet.getAccountByPath("0'/0/1");Source
src/wallet-manager-ton-gasless.js#L68
getFeeRates()
Returns the current fee rates.
Returns
Promise<FeeRates> - The fee rates (in nanotons).
Source
src/wallet-manager-ton-gasless.js#L83
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. |
WalletAccountReadOnlyTonGasless
Extends @tetherto/wdk-wallet
Constructor
new WalletAccountReadOnlyTonGasless(publicKey, config)Parameters
publicKey(string | Uint8Array<ArrayBufferLike>): The account's public key.config(Omit<TonGaslessWalletConfig, "transferMaxFee">): The configuration object.
Source
src/wallet-account-read-only-ton-gasless.js#L66
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_getGaslessTokenTransferMessage(options) | Creates and returns an internal message to execute the given token transfer. | Promise<MessageRelaxed> | - |
_getGaslessTokenTransferRawParams(message, config) | Creates and returns the ton api's raw parameters to execute the given message. | Promise<SignRawParams> | - |
getAddress() | Returns the account's address. | Promise<string> | - |
getBalance() | Returns the account's ton balance. | Promise<bigint> | - |
getPaymasterTokenBalance() | Returns the account's balance for the paymaster token provided in the wallet account configuration. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific token. | Promise<bigint> | - |
getTransactionReceipt(hash) | Returns a transaction's receipt. | Promise<Transaction> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options, config) | Quotes the costs of a transfer operation. | Promise<Omit<TransferResult, "hash">> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
_getGaslessTokenTransferMessage(options)
Creates and returns an internal message to execute the given token transfer.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<MessageRelaxed> - The internal message.
Source
src/wallet-account-read-only-ton-gasless.js#L180
_getGaslessTokenTransferRawParams(message, config)
Creates and returns the ton api's raw parameters to execute the given message.
Parameters
message(MessageRelaxed): The message.config(Pick<TonGaslessWalletConfig, "paymasterToken">): The configuration object.
Returns
Promise<SignRawParams> - The ton api's raw parameters.
Source
src/wallet-account-read-only-ton-gasless.js#L218
getAddress()
Returns the account's address.
Returns
Promise<string> - The account's address.
getBalance()
Returns the account's ton balance.
Returns
Promise<bigint> - The ton balance (in nanotons).
Source
src/wallet-account-read-only-ton-gasless.js#L102
getPaymasterTokenBalance()
Returns the account's balance for the paymaster token provided in the wallet account configuration.
Returns
Promise<bigint> - The paymaster token balance (in base unit).
Source
src/wallet-account-read-only-ton-gasless.js#L121
getTokenBalance(tokenAddress)
Returns the account balance for a specific 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-ton-gasless.js#L112
getTransactionReceipt(hash)
Returns a transaction's receipt.
Parameters
hash(string): The transaction's hash.
Returns
Promise<Transaction> - - The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-ton-gasless.js#L169
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(TonTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-ton-gasless.js#L133
quoteTransfer(options, config)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.config(Pick<TonGaslessWalletConfig, "paymasterToken">, optional): If set, overrides the 'paymasterToken' options defined in the wallet account configuration.
Returns
Promise<Omit<TransferResult, "hash">> - The transfer's quotes.
Source
src/wallet-account-read-only-ton-gasless.js#L144
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-ton-gasless.js#L159
Properties
| Property | Type | Description |
|---|---|---|
_address | string | The account's address. |
WalletAccountTonGasless
Extends @tetherto/wdk-wallet-ton-gasless
Constructor
new WalletAccountTonGasless(seed, path, config)Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.path(string): The BIP-44 derivation path (e.g. "0'/0/0").config(TonGaslessWalletConfig): The configuration object.
Source
src/wallet-account-ton-gasless.js#L42
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_getGaslessTokenTransferMessage(options) | Creates and returns an internal message to execute the given token transfer. | Promise<MessageRelaxed> | - |
_getGaslessTokenTransferRawParams(message, config) | Creates and returns the ton api's raw parameters to execute the given message. | Promise<SignRawParams> | - |
dispose() | Disposes the wallet account, erasing the private key from the memory. | void | - |
getAddress() | Returns the account's address. | Promise<string> | - |
getBalance() | Returns the account's ton balance. | Promise<bigint> | - |
getPaymasterTokenBalance() | Returns the account's balance for the paymaster token provided in the wallet account configuration. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific token. | Promise<bigint> | - |
getTransactionReceipt(hash) | Returns a transaction's receipt. | Promise<Transaction> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options, config) | 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. Not supported on ton gasless: this module only supports gasless token transfers via the transfer method, which relays a signed internal message through the gasless provider. | Promise<never> | - |
toReadOnlyAccount() | Returns a read-only copy of the account. | Promise<WalletAccountReadOnlyTonGasless> | - |
transfer(options, config) | Transfers a token to another address. | Promise<TransferResult> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
_getGaslessTokenTransferMessage(options)
Creates and returns an internal message to execute the given token transfer.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<MessageRelaxed> - The internal message.
Source
src/wallet-account-read-only-ton-gasless.js#L180
_getGaslessTokenTransferRawParams(message, config)
Creates and returns the ton api's raw parameters to execute the given message.
Parameters
message(MessageRelaxed): The message.config(Pick<TonGaslessWalletConfig, "paymasterToken">): The configuration object.
Returns
Promise<SignRawParams> - The ton api's raw parameters.
Source
src/wallet-account-read-only-ton-gasless.js#L218
dispose()
Disposes the wallet account, erasing the private key from the memory.
Returns
void
Source
src/wallet-account-ton-gasless.js#L161
getAddress()
Returns the account's address.
Returns
Promise<string> - The account's address.
getBalance()
Returns the account's ton balance.
Returns
Promise<bigint> - The ton balance (in nanotons).
Source
src/wallet-account-read-only-ton-gasless.js#L102
getPaymasterTokenBalance()
Returns the account's balance for the paymaster token provided in the wallet account configuration.
Returns
Promise<bigint> - The paymaster token balance (in base unit).
Source
src/wallet-account-read-only-ton-gasless.js#L121
getTokenBalance(tokenAddress)
Returns the account balance for a specific 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-ton-gasless.js#L112
getTransactionReceipt(hash)
Returns a transaction's receipt.
Parameters
hash(string): The transaction's hash.
Returns
Promise<Transaction> - - The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-ton-gasless.js#L169
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(TonTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-ton-gasless.js#L133
quoteTransfer(options, config)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.config(Pick<TonGaslessWalletConfig, "paymasterToken">, optional): If set, overrides the 'paymasterToken' options defined in the wallet account configuration.
Returns
Promise<Omit<TransferResult, "hash">> - The transfer's quotes.
Source
src/wallet-account-read-only-ton-gasless.js#L144
sendTransaction(tx)
Sends a transaction.
Parameters
tx(TonTransaction): The transaction.
Returns
Promise<TransactionResult> - The transaction's result.
Source
src/wallet-account-ton-gasless.js#L115
sign(message)
Signs a message.
Parameters
message(string): The message to sign.
Returns
Promise<string> - The message's signature.
Source
src/wallet-account-ton-gasless.js#L92
signTransaction(tx)
Signs a transaction.
Not supported on ton gasless: this module only supports gasless token transfers via
the transfer method, which relays a signed internal message through the gasless provider.
Parameters
tx(TonTransaction): The transaction.
Returns
Promise<never> - Never resolves; always throws.
Source
src/wallet-account-ton-gasless.js#L105
toReadOnlyAccount()
Returns a read-only copy of the account.
Returns
Promise<WalletAccountReadOnlyTonGasless> - The read-only account.
Source
src/wallet-account-ton-gasless.js#L150
transfer(options, config)
Transfers a token to another address.
Parameters
options(TransferOptions): The transfer's options.config(Pick<TonGaslessWalletConfig, "paymasterToken" | unknown>, optional): If set, overrides the 'paymasterToken' and 'transferMaxFee' options defined in the wallet account configuration.
Returns
Promise<TransferResult> - The transfer's result.
Source
src/wallet-account-ton-gasless.js#L126
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-ton-gasless.js#L159
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. |
path | string | The derivation path of this account (see BIP-44). |
Types
TonApiClientConfig
| Property | Type | Description |
|---|---|---|
secretKey? | string | If set, uses the api-key to authenticate on the ton api. |
url | string | The url of the ton api. |
Source
src/wallet-account-read-only-ton-gasless.js#L43
TonClientConfig
| Property | Type | Description |
|---|---|---|
secretKey? | string | If set, uses the api-key to authenticate on the ton center api. |
url | string | The url of the ton center api. |
Source
src/wallet-account-read-only-ton-gasless.js#L37
TonGaslessWalletConfig
| Property | Type | Description |
|---|---|---|
paymasterToken | object | The paymaster token configuration. |
tonApiClient | `TonApiClientConfig | TonApiClient` |
tonClient | `TonClient | TonClientConfig` |
transferMaxFee? | `number | bigint` |