@ledgerhq/hw-app-aptos
TypeScript icon, indicating that this package has built-in type declarations

6.34.0 • Public • Published

GitHub, Ledger Devs Discord, Developer Portal

@ledgerhq/hw-app-aptos

Ledger Hardware Wallet Aptos JavaScript bindings.


Are you adding Ledger support to your software wallet?

You may be using this package to communicate with the Aptos Nano App.

For a smooth and quick integration:

  • See the developers’ documentation on the Developer Portal and
  • Go on Discord to chat with developer support and the developer community.

API

Table of Contents

Aptos

Aptos API

Parameters

  • transport Transport
  • scrambleKey (optional, default "aptos")

Examples

import Transport from "@ledgerhq/hw-transport";
import Aptos from "@ledgerhq/hw-app-aptos";

function establishConnection() {
    return Transport.create()
        .then(transport => new Aptos(transport));
}

function fetchAddress(aptosClient) {
    return aptosClient.getAddress("44'/144'/0'/0/0");
}

function signTransaction(aptosClient, deviceData, seqNo, buffer) { *
    const transactionBlob = encode(buffer);

    console.log('Sending transaction to device for approval...');
    return aptosClient.signTransaction("44'/144'/0'/0/0", transactionBlob);
}

function prepareAndSign(aptosClient, seqNo) {
    return fetchAddress(aptosClient)
        .then(deviceData => signTransaction(aptosClient, deviceData, seqNo));
}

establishConnection()
    .then(aptos => prepareAndSign(aptos, 123, payload))
    .then(signature => console.log(`Signature: ${signature}`))
    .catch(e => console.log(`An error occurred (${e.message})`));

getAddress

get Aptos address for a given BIP 32 path.

Parameters
  • path string a path in BIP 32 format
  • display optionally enable or not the display (optional, default false)
Examples
const result = await aptos.getAddress("44'/144'/0'/0/0");
const { publicKey, address } = result;

Returns Promise<AddressData> an object with a publicKey, address and (optionally) chainCode

signTransaction

sign a Aptos transaction with a given BIP 32 path

Parameters
  • path string a path in BIP 32 format
  • txBuffer Buffer the buffer to be signed for transaction
Examples
const signature = await aptos.signTransaction("44'/144'/0'/0/0", "12000022800000002400000002614000000001315D3468400000000000000C73210324E5F600B52BB3D9246D49C4AB1722BA7F32B7A3E4F9F2B8A1A28B9118CC36C48114F31B152151B6F42C1D61FE4139D34B424C8647D183142ECFC1831F6E979C6DA907E88B1CAD602DB59E2F");

Returns Promise<{signature: Buffer}> a signature as hex string

bippath

BIP32 Path Handling for Aptos Wallets

This file provides utility functions to handle BIP32 paths, which are commonly used in hierarchical deterministic (HD) wallets. It includes functions to convert BIP32 paths to and from different formats, extract components from extended public keys (xpubs), and manipulate path elements.

Package Sidebar

Install

npm i @ledgerhq/hw-app-aptos

Weekly Downloads

8,291

Version

6.34.0

License

Apache-2.0

Unpacked Size

57.2 kB

Total Files

28

Last publish

Collaborators

  • phenry-ledger
  • sergii-shkolin
  • gbrahm-ledger
  • aboissiere
  • thomas.coudray
  • ldg-github-ci
  • vbouzon
  • ledger-releaser