Wallet Aptos API Reference
API reference for @tetherto/wdk-wallet-aptos.
Exports
import WalletManagerAptos, {
WalletAccountAptos,
WalletAccountReadOnlyAptos,
type AptosTransactionInfo,
type WaitForTransactionOptions
} from '@tetherto/wdk-wallet-aptos'WalletManagerAptos
Creates and manages seed-derived Aptos accounts.
new WalletManagerAptos(
seed: string | Uint8Array,
config?: AptosWalletConfig
)Methods
| Method | Description | Returns |
|---|---|---|
getAccount(index?) | Returns the account at m/44'/637'/index'/0'/0'. | Promise<WalletAccountAptos> |
getAccountByPath(path) | Returns an account at a relative hardened path. | Promise<WalletAccountAptos> |
getFeeRates() | Returns Aptos fee rates in octas per gas unit. | Promise<FeeRates> |
dispose() | Disposes cached accounts and signers and clears their manager caches. It does not erase the manager's seed buffer. | void |
WalletAccountAptos
Writable Aptos account with signing and transaction submission support.
new WalletAccountAptos(
seed: string | Uint8Array,
path: string,
config?: AptosWalletConfig
)Properties
| Property | Description |
|---|---|
index | Index parsed from the derivation path. |
path | Full derivation path, including the m/44'/637' prefix. |
keyPair | Public/private key byte-array views. Treat them as read-only. The private key is unavailable after dispose(). |
Methods
| Method | Description | Returns |
|---|---|---|
getAddress() | Returns the Aptos account address. | Promise<string> |
getBalance() | Returns the native APT balance in octas. | Promise<bigint> |
getTokenBalance(tokenAddress) | Returns a fungible asset balance by metadata address. | Promise<bigint> |
quoteSendTransaction(tx) | Estimates fee for a native APT transfer. | Promise<{ fee: bigint }> |
sendTransaction(tx) | Signs and submits a native APT transfer. | Promise<TransactionResult> |
signTransaction(tx) | Simulates and signs a native APT transfer without broadcasting. Requires a provider. | Promise<SignedTransaction> |
quoteTransfer(options) | Estimates fee for a fungible asset transfer. | Promise<{ fee: bigint }> |
transfer(options) | Signs and submits a fungible asset transfer. | Promise<TransferResult> |
getTransaction(hash) | Returns a normalized receipt plus the raw Aptos transaction. | Promise<AptosTransactionInfo> |
waitForTransaction(hash, options?) | Polls until the requested finality or timeout. | Promise<AptosTransactionInfo> |
getTransactionReceipt(hash) | Deprecated raw lookup for a pending or committed Aptos transaction. | Promise<{ type: string; hash: string; success?: boolean; vm_status?: string } | null> |
sign(message) | Signs a message with the account key. | Promise<string> |
verify(message, signature) | Verifies a message signature. | Promise<boolean> |
toReadOnlyAccount() | Returns a read-only account for the same address. | Promise<WalletAccountReadOnlyAptos> |
dispose() | Clears private key material from memory. | void |
WalletAccountReadOnlyAptos
Read-only account for address-based reads and verification.
new WalletAccountReadOnlyAptos(
address: string,
config?: AptosWalletConfig,
publicKey?: Uint8Array
)An address-only instance supports balance reads and transaction tracking. quoteSendTransaction(), quoteTransfer(), and verify() require the matching public key because an Aptos address cannot be reversed into an Ed25519 public key. toReadOnlyAccount() supplies that key automatically.
The read-only constructor stores the supplied address as-is; it does not validate or normalize it. Validate an externally supplied address before constructing the account.
| Method | Description | Returns |
|---|---|---|
getAddress() | Returns the constructor-supplied address verbatim. | Promise<string> |
getBalance() | Returns the native APT balance in octas. | Promise<bigint> |
getTokenBalance(tokenAddress) | Returns a fungible asset balance by metadata address. | Promise<bigint> |
quoteSendTransaction(tx) | Estimates fee for a native APT transfer. | Promise<{ fee: bigint }> |
quoteTransfer(options) | Estimates fee for a fungible asset transfer. | Promise<{ fee: bigint }> |
getTransaction(hash) | Returns a normalized receipt plus the raw Aptos transaction. | Promise<AptosTransactionInfo> |
waitForTransaction(hash, options?) | Polls until the requested finality or timeout. | Promise<AptosTransactionInfo> |
getTransactionReceipt(hash) | Deprecated raw lookup for a pending or committed Aptos transaction. | Promise<{ type: string; hash: string; success?: boolean; vm_status?: string } | null> |
verify(message, signature) | Verifies a message signature. Requires the matching public key. | Promise<boolean> |
Config Type
type AptosWalletConfig = {
provider?: string | string[]
chainId?: number
retries?: number
txnExpirationSecs?: number
transferMaxFee?: number | bigint
}| Field | Default and behavior |
|---|---|
provider | No default. An array enables endpoint failover. |
chainId | Fetched from ledger info on first use when omitted. A supplied value must match the provider network. |
retries | 3 for a provider array. |
txnExpirationSecs | 60. |
transferMaxFee | No default. Applies only to fungible asset transfer() and rejects fees at or above the cap. |
Transaction Types
type AptosTransaction = {
to: string
value: number | bigint
}
type TransferOptions = {
token: string
recipient: string
amount: number | bigint
}token is an Aptos fungible asset metadata address.
Result Types
type TransactionResult = {
hash: string
fee: bigint
}
type TransferResult = {
hash: string
fee: bigint
}Transaction Tracking
Use getTransaction() for one normalized lookup or waitForTransaction() to poll. Both methods accept a transaction hash after trimming whitespace; the remaining value must be 0x followed by 64 hexadecimal characters.
type AptosTransactionInfo = TransactionReceipt & {
transaction: AptosReceiptShape
}
type TransactionReceipt = {
hash: string
finality: 'pending' | 'confirmed' | 'final' | 'dropped'
success?: boolean
block?: number
fee?: bigint
}A mempool transaction returns finality: 'pending'. Any committed Aptos transaction returns finality: 'final'; this module does not emit an intermediate confirmed state or dropped. For committed transactions, block is the numeric transaction version, fee is gas_used * gas_unit_price, and success reports VM execution outcome. A final receipt can therefore still have success: false.
An invalid hash throws ValueError; a valid but unknown hash throws NoSuchElementError. waitForTransaction() treats not-found as transient, polls every 4 seconds by default, and times out after 60 seconds unless overridden. Its default confirmed target is satisfied when Aptos reports the transaction as final.
const receipt = await account.waitForTransaction(result.hash, {
target: 'final',
timeout: 120000
})
if (receipt.success === false) {
console.error('Transaction failed:', receipt.transaction.vm_status)
}getTransactionReceipt() is retained as a deprecated raw lookup with three observable states. The package root does not export an AptosTransactionReceipt type; the released declaration uses type: string. The following is the portable declared shape:
type AptosReceiptShape = {
type: string
hash: string
success?: boolean
vm_status?: string
version?: string
gas_used?: string
gas_unit_price?: string
}null: the fullnode does not know the hash.- An observed
typeofpending_transaction: accepted into the mempool;successandvm_statusare absent. - An observed
typeofuser_transaction: committed; inspectsuccessandvm_statusto determine execution outcome.
Signed Transaction
signTransaction(tx) returns a JSON-form signed transaction accepted by the Aptos REST API. It includes sender, sequence number, gas fields, payload, and Ed25519 signature. Before signing, the module uses the configured provider to simulate the transaction and obtain sequence, gas, and chain data. A failed simulation prevents signing.
signTransaction() does not broadcast, but it is not an offline operation. It signs native APT transfers only. Use transfer() for fungible asset transfers.
transferMaxFee does not protect native sendTransaction() or signTransaction() calls. A native quote can support user review, but send and sign simulate again and expose no hard maximum-fee control in beta.2.