Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

vulet/helios-transport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helios-transport

Ledger Hardware Wallet HNT JavaScript bindings.

Installation

yarn add helios-transport

Examples

import TransportBLE from '@ledgerhq/hw-transport-web-ble';
import TransportHID from '@ledgerhq/hw-transport-node-hid';
import { PaymentV1 } from '@helium/transactions';
import { Client } from '@helium/http';
import { HNT } from 'helios-transport';

// start web Bluetooth connection
const hnt = await TransportBLE.create()
  .then((transport) => new HNT(transport));

// start node USB connection
const hnt = await TransportHID.create()
  .then((transport) => new HNT(transport));
// base58 address
const base58Address = await hnt.getPublicKey().then((o) => o.b58);
// address_index support
const address = await hnt.getPublicKey(112);
// Prepare @helium-js PaymentV1 transaction
const paymentTxn = new PaymentV1({
  payer: bob,
  payee: alice,
  amount: 10,
  nonce: account.speculativeNonce + 1,
});

// create Ledger signature
const signedTxn = await hnt.signPaymentV1(paymentTxn);
paymentTxn.signature = signedTxn.signature;

// submit transaction
client.transactions.submit(paymentTxn.toString());
// Prepare @helium-js TokenBurnV1 transaction
const burnTxn = new burnTxn({
  payer: bob,
  payee: alice,
  amount: 1,
  nonce: account.speculativeNonce + 1,
  memo: 'AAAAAAAAAAA=',
});

// create Ledger signature
const signedTxn = await hnt.signBurnV1(burnTxn);
burnTxn.signature = signedTxn.signature;

// submit transaction
client.transactions.submit(burnTxn.toString());

Contributors

This project is made great by its contributors.