WDK logoWDK documentation

Wallet Aptos Usage

Install and use @tetherto/wdk-wallet-aptos for Aptos accounts, balances, transfers, and signing.

Install

npm install @tetherto/wdk-wallet-aptos

Create a Wallet Manager

import WalletManagerAptos from '@tetherto/wdk-wallet-aptos'

const wallet = new WalletManagerAptos(seedPhrase, {
  provider: 'https://fullnode.mainnet.aptoslabs.com/v1',
  transferMaxFee: 100000n
})

const account = await wallet.getAccount(0)
const address = await account.getAddress()

Manage Accounts

const first = await wallet.getAccount(0)
const second = await wallet.getAccount(1)

const custom = await wallet.getAccountByPath("5'/0'/0'")

console.log(await first.getAddress())
console.log(await second.getAddress())
console.log(await custom.getAddress())

getAccount(index) maps to m/44'/637'/index'/0'/0'.

Read Balances

const aptBalance = await account.getBalance()
console.log('APT balance in octas:', aptBalance)

const usdtMetadataAddress =
  '0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b'

const usdtBalance = await account.getTokenBalance(usdtMetadataAddress)
console.log('USDT balance:', usdtBalance)

Read-only accounts support the same balance reads without a seed phrase.

import { WalletAccountReadOnlyAptos } from '@tetherto/wdk-wallet-aptos'

const readOnlyAccount = new WalletAccountReadOnlyAptos('0x...', {
  provider: 'https://fullnode.mainnet.aptoslabs.com/v1'
})

const balance = await readOnlyAccount.getBalance()

An address-only account can read balances and receipts. Fee quotes and message verification also need the matching Ed25519 public key. Use account.toReadOnlyAccount() when possible; the returned account includes it.

Send Native APT

const nativeFeeLimit = 100000n

const quote = await account.quoteSendTransaction({
  to: '0x...',
  value: 100000000n
})

console.log('Estimated fee in octas:', quote.fee)

if (quote.fee >= nativeFeeLimit) {
  throw new Error('Native APT fee is at or above the application limit')
}

const result = await account.sendTransaction({
  to: '0x...',
  value: 100000000n
})

console.log('Transaction hash:', result.hash)
console.log('Fee in octas:', result.fee)

sendTransaction() submits a native APT transfer through 0x1::aptos_account::transfer.

Transfer Fungible Assets

Use the fungible asset metadata address as token.

const quote = await account.quoteTransfer({
  token: usdtMetadataAddress,
  recipient: '0x...',
  amount: 1000000n
})

console.log('Estimated fee in octas:', quote.fee)

const result = await account.transfer({
  token: usdtMetadataAddress,
  recipient: '0x...',
  amount: 1000000n
})

console.log('Transfer hash:', result.hash)
console.log('Fee in octas:', result.fee)

transfer() submits 0x1::primary_fungible_store::transfer and can auto-create the recipient primary store.

When configured, transferMaxFee applies to this fungible asset flow only. transfer() rejects an estimated fee at or above the cap.

Sign and Verify Messages

const message = 'Hello, Aptos'
const signature = await account.sign(message)

const readOnly = await account.toReadOnlyAccount()
const valid = await readOnly.verify(message, signature)

console.log('Signature valid:', valid)

Sign Native APT Transfers Without Broadcasting

signTransaction() simulates and signs a native APT transfer without broadcasting it. It still calls the configured fullnode for account sequence, gas, chain, and simulation data.

const signed = await account.signTransaction({
  to: '0x...',
  value: 100000000n
})

console.log('Signed Aptos transaction:', signed)

This is not an offline operation. A failed simulation prevents signing. Fungible asset transfers are built and submitted through transfer().

transferMaxFee does not apply to native APT signing or sending. Quote the transfer and enforce your own native-fee limit before signing or submitting:

const nativeFeeLimit = 100000n

const quote = await account.quoteSendTransaction({
  to: '0x...',
  value: 100000000n
})

if (quote.fee >= nativeFeeLimit) {
  throw new Error('Native APT fee is at or above the application limit')
}

Check Transaction Status

const receipt = await account.getTransactionReceipt(result.hash)

if (!receipt) {
  console.log('Transaction is not known to this fullnode')
} else if (receipt.type === 'pending_transaction') {
  console.log('Transaction is pending')
} else if (!receipt.success) {
  console.error('Transaction failed:', receipt.vm_status)
}

A non-null receipt is not necessarily final. Wait for type === 'user_transaction', then inspect success.

Dispose Secret Material

account.dispose()
wallet.dispose()

On this page