Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/docs/sdk/all-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Wallet modules provide blockchain-specific wallet functionality for managing add
| [`@tetherto/wdk-wallet-tron`](https://github.com/tetherto/wdk-wallet-tron) | TRON | TRON blockchain wallet | [Docs](/sdk/wallet-modules/wallet-tron/) |
| [`@tetherto/wdk-wallet-tron-gasfree`](https://github.com/tetherto/wdk-wallet-tron-gasfree) | TRON | Gas-free transactions on TRON | [Docs](/sdk/wallet-modules/wallet-tron-gasfree/) |
| [`@tetherto/wdk-wallet-solana`](https://github.com/tetherto/wdk-wallet-solana) | Solana | Solana blockchain wallet | [Docs](/sdk/wallet-modules/wallet-solana/) |
| [`@tetherto/wdk-wallet-aptos`](https://github.com/tetherto/wdk-wallet-aptos) | Aptos | Aptos blockchain wallet with native APT and fungible asset support | [Docs](/sdk/wallet-modules/wallet-aptos/) |
| [`@tetherto/wdk-wallet-spark`](https://github.com/tetherto/wdk-wallet-spark) | Spark | Spark/Lightning Bitcoin L2 wallet | [Docs](/sdk/wallet-modules/wallet-spark/) |

## Swidge Interface
Expand Down
1 change: 1 addition & 0 deletions content/docs/sdk/wallet-modules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Standard wallet implementations that use native blockchain tokens for transactio
| [`@tetherto/wdk-wallet-spark`](https://github.com/tetherto/wdk-wallet-spark) | Spark | ✅ Ready | [Documentation](/sdk/wallet-modules/wallet-spark) |
| [`@tetherto/wdk-wallet-tron`](https://github.com/tetherto/wdk-wallet-tron) | TRON | ✅ Ready | [Documentation](/sdk/wallet-modules/wallet-tron) |
| [`@tetherto/wdk-wallet-solana`](https://github.com/tetherto/wdk-wallet-solana) | Solana | ✅ Ready | [Documentation](/sdk/wallet-modules/wallet-solana) |
| [`@tetherto/wdk-wallet-aptos`](https://github.com/tetherto/wdk-wallet-aptos) | Aptos | In review | [Documentation](/sdk/wallet-modules/wallet-aptos) |
| [`@arkade-os/wdk`](https://github.com/arkade-os/arkade-wdk) | Arkade | ✅ Ready | [README](https://github.com/arkade-os/arkade-wdk#readme) |

## Account Abstraction Wallet Modules
Expand Down
152 changes: 152 additions & 0 deletions content/docs/sdk/wallet-modules/wallet-aptos/api-reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
title: Wallet Aptos API Reference
description: API reference for @tetherto/wdk-wallet-aptos.
docType: reference
schemaType: APIReference
icon: Code
---

## Exports

```javascript
import WalletManagerAptos, {
WalletAccountAptos,
WalletAccountReadOnlyAptos
} from '@tetherto/wdk-wallet-aptos'
```

## WalletManagerAptos

Creates and manages seed-derived Aptos accounts.

```typescript
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()` | Clears managed account secret material. | `void` |

## WalletAccountAptos

Writable Aptos account with signing and transaction submission support.

```typescript
new WalletAccountAptos(
seed: string | Uint8Array,
path: string,
config?: AptosWalletConfig
)
```

### Properties

| Property | Description |
|----------|-------------|
| `index` | Index parsed from the derivation path. |
| `path` | Relative derivation path. |
| `keyPair` | Public/private key pair view. 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)` | Signs a native APT transfer without broadcasting. | `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>` |
| `getTransactionReceipt(hash)` | Looks up a transaction receipt. | `Promise<TransactionReceipt \| 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.

```typescript
new WalletAccountReadOnlyAptos(
address: string,
config?: AptosWalletConfig
)
```

| Method | Description | Returns |
|--------|-------------|---------|
| `getAddress()` | Returns the normalized Aptos 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 }>` |
| `quoteTransfer(options)` | Estimates fee for a fungible asset transfer. | `Promise<{ fee: bigint }>` |
| `getTransactionReceipt(hash)` | Looks up a transaction receipt. | `Promise<TransactionReceipt \| null>` |
| `verify(message, signature)` | Verifies a message signature. | `Promise<boolean>` |

## Config Type

```typescript
type AptosWalletConfig = {
provider?: string
transferMaxFee?: number | bigint
}
```

## Transaction Types

```typescript
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

```typescript
type TransactionResult = {
hash: string
fee: bigint
}

type TransferResult = {
hash: string
fee: bigint
}
```

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

<Callout type="warn">
`signTransaction()` signs native APT transfers only. Use `transfer()` for fungible asset transfers.
</Callout>

<Cards>
<Card title="Usage" href="/sdk/wallet-modules/wallet-aptos/usage">
Create accounts, read balances, transfer funds, and sign messages.
</Card>
<Card title="Configuration" href="/sdk/wallet-modules/wallet-aptos/configuration">
Provider, network, fee, and derivation path options.
</Card>
</Cards>
102 changes: 102 additions & 0 deletions content/docs/sdk/wallet-modules/wallet-aptos/configuration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Wallet Aptos Configuration
description: Configuration options for @tetherto/wdk-wallet-aptos.
docType: reference
schemaType: TechArticle
icon: Settings
---

Configure the Aptos wallet module with an Aptos fullnode REST endpoint. A provider is required for balance reads, fee quotes, transaction submission, and receipt polling.

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

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

## Wallet Configuration

| Option | Type | Description |
|--------|------|-------------|
| `provider` | `string` | Aptos fullnode REST API URL. Required for chain operations. |
| `transferMaxFee` | `number \| bigint` | Optional maximum fee in octas for transfer operations. |

## Account Configuration

You can construct accounts directly when you need a specific derivation path.

```javascript
import { WalletAccountAptos } from '@tetherto/wdk-wallet-aptos'

const account = new WalletAccountAptos(seedPhrase, "0'/0'/0'", {
provider: 'https://fullnode.mainnet.aptoslabs.com/v1',
transferMaxFee: 100000n
})
```

Read-only accounts require only an address and provider configuration.

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

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

## Network Selection

Network selection is controlled by the fullnode URL.

| Network | Provider URL |
|---------|--------------|
| Mainnet | `https://fullnode.mainnet.aptoslabs.com/v1` |
| Testnet | `https://fullnode.testnet.aptoslabs.com/v1` |

## Derivation Paths

The module uses SLIP-0010 Ed25519 derivation. `getAccount(index)` derives:

```text
m/44'/637'/index'/0'/0'
```

Use `getAccountByPath(path)` to provide a relative path after `m/44'/637'/`.

```javascript
const account = await wallet.getAccountByPath("5'/0'/0'")
```

<Callout type="warn">
Every Aptos path segment must be hardened. A path segment without an apostrophe is invalid for this module's Ed25519 derivation.
</Callout>

## Fee Limit

`transferMaxFee` caps estimated transaction fees before signing and submitting transfer operations.

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

## Security Notes

- Keep seed phrases and seed bytes outside logs and client-visible error reporting.
- Use trusted fullnode endpoints for production wallets.
- Set a fee cap for user-facing transfers.
- Call `dispose()` on accounts and managers when secret material is no longer needed.

<Cards>
<Card title="Usage" href="/sdk/wallet-modules/wallet-aptos/usage">
Create accounts, read balances, send transactions, and transfer fungible assets.
</Card>
<Card title="API Reference" href="/sdk/wallet-modules/wallet-aptos/api-reference">
Detailed class, method, config, and type reference.
</Card>
</Cards>
64 changes: 64 additions & 0 deletions content/docs/sdk/wallet-modules/wallet-aptos/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Wallet Aptos Overview
description: Overview of the @tetherto/wdk-wallet-aptos module.
docType: explanation
schemaType: TechArticle
---

The Aptos wallet module manages SLIP-0010 Ed25519 accounts for the Aptos blockchain through the shared WDK wallet interfaces.

Use this module when an app needs Aptos account derivation, APT balances, fungible asset balances, native APT transfers, fungible asset transfers, fee quotes, message signing, and read-only account support.

## Features

- **BIP-39 seed support**: Accepts a mnemonic phrase or seed bytes.
- **SLIP-0010 Ed25519 derivation**: Uses Aptos coin type `637` and hardened path segments.
- **Aptos addresses**: Derives 32-byte Aptos addresses from the public key.
- **Native APT support**: Sends native APT through `0x1::aptos_account::transfer`.
- **Fungible asset support**: Reads and transfers Aptos fungible assets by metadata address.
- **Fee estimation**: Simulates transactions to estimate gas before signing and submitting.
- **Message signing**: Signs and verifies messages with Ed25519 keys.
- **Read-only accounts**: Reads balances, quotes fees, verifies signatures, and checks receipts without private keys.
- **Bare runtime compatibility**: Uses the Aptos fullnode REST API over `fetch` instead of the Aptos SDK at runtime.

## Supported Networks

| Network | Chain ID | Fullnode example |
|---------|----------|------------------|
| Aptos Mainnet | `1` | `https://fullnode.mainnet.aptoslabs.com/v1` |
| Aptos Testnet | `2` | `https://fullnode.testnet.aptoslabs.com/v1` |

## Aptos-Specific Behavior

| Area | Behavior |
|------|----------|
| Default derivation path | `m/44'/637'/account'/0'/0'` |
| `getAccount(index)` mapping | Uses `index` as the `account` segment. |
| Token model | Uses Aptos fungible asset metadata addresses, not coin type tags. |
| APT units | APT balances and fees are returned in octas. |
| Token transfers | `transfer()` builds and submits `0x1::primary_fungible_store::transfer`. |
| Offline signing | `signTransaction()` supports native APT transfers. Use `transfer()` for fungible asset transfers. |

<Callout type="info">
All Aptos derivation path segments are hardened because the module uses Ed25519 with SLIP-0010 derivation.
</Callout>

## Next Steps

<Cards>
<Card title="Configuration" href="/sdk/wallet-modules/wallet-aptos/configuration">
Configure Aptos fullnode access, derivation paths, and fee limits.
</Card>
<Card title="Usage" href="/sdk/wallet-modules/wallet-aptos/usage">
Install the package, create accounts, read balances, send APT, transfer fungible assets, and sign messages.
</Card>
<Card title="API Reference" href="/sdk/wallet-modules/wallet-aptos/api-reference">
Review manager, account, read-only account, config, transaction, and result types.
</Card>
</Cards>

---

## Need Help?

<SupportCards />
Loading