Code Monkey home page Code Monkey logo

ledger-decimal-js's Introduction

ledger-cosmos-js

License

This package provides a basic client library to communicate with a Decimal App running in a Ledger Nano S/X

This repo also includes a simple Vue example for U2F and WebUSB.

Example

Methods for ledger Nano

Serialize human readable part of Bech32 (HRP).

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const serializehrp = _decimal.serializeHRP('dx');

Get Bech32 from PK

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const bech32 = _decimal.getBech32FromPK('dx', pk);

Serialize derivation path

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const serializePath = await _decimal.serializePath('dx', path);

Sign get Chunks

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const signedChunks = await _decimal.signGetChunks(path, messageVariable);

Get app version

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const version = await _decimal.getVersion();

Get app info

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const appInfo = await _decimal.appInfo();

Get device info

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const deviceInfo = await _decimal.deviceInfo();

Get public key

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const publicKey = await _decimal.publicKey(path);

Get address and public key

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const wallet = await _decimal.getAddressAndPubKey(path, 'dx');

Sign send Chunk

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const res = await _decimal.signSendChunk(chunkIdx, chunkNum, chunk);

Sing transaction

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const res = await _decimal.sign(path, unsignedTx);

ledger-decimal-js's People

Contributors

jleni avatar svyats avatar fedekunze avatar wardencliffe avatar andreikozak avatar dependabot[bot] avatar pblaravel avatar webdozerz avatar

Watchers

 avatar Sanadar avatar

Forkers

ziutop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.