GitHub, Ledger Devs Discord, Developer Portal
Ledger Hardware Wallet Aptos JavaScript bindings.
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.
Aptos API
-
transport
Transport -
scrambleKey
(optional, default"aptos"
)
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})`));
get Aptos address for a given BIP 32 path.
-
path
string a path in BIP 32 format -
display
optionally enable or not the display (optional, defaultfalse
)
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
sign a Aptos transaction with a given BIP 32 path
const signature = await aptos.signTransaction("44'/144'/0'/0/0", "12000022800000002400000002614000000001315D3468400000000000000C73210324E5F600B52BB3D9246D49C4AB1722BA7F32B7A3E4F9F2B8A1A28B9118CC36C48114F31B152151B6F42C1D61FE4139D34B424C8647D183142ECFC1831F6E979C6DA907E88B1CAD602DB59E2F");
Returns Promise<{signature: Buffer}> a signature as hex string
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.