@rnssolution/color-ledger
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Color Ledger App wrapper

This library helps interfacing with Color Ledger App. It provides a developer friendly interface and user friendly error messages.

Install

yarn add @rnssolution/color-ledger

Usage

Sign using the Ledger

import Ledger from "@rnssolution/color-ledger"

const signMessage = ... message to sign, generate messages with "@lunie/cosmos-js"

const ledger = await Ledger().connect()

const signature = await ledger.sign(signMessage)

Using with cosmos-js

import Ledger from "@rnssolution/color-ledger"
import Cosmos from "@lunie/cosmos-js"

const privateKey = Buffer.from(...)
const publicKey = Buffer.from(...)

// init cosmos sender
const cosmos = Cosmos(STARGATE_URL, ADDRESS)

// create message
const msg = cosmos
  .MsgSend({toAddress: 'color1abcd09876', amounts: [{ denom: 'color', amount: 10 }})

// create a signer from this local js signer library
const ledgerSigner = async (signMessage) => {
  const ledger = await Ledger().connect()
  const publicKey = await ledger.getPubKey()
  const signature = await ledger.sign(signMessage)

  return {
    signature,
    publicKey
  }
}

// send the transaction
const { included }= await msg.send({ gas: 200000 }, ledgerSigner)

// await tx to be included in a block
await included()

Package Sidebar

Install

npm i @rnssolution/color-ledger

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

2 MB

Total Files

6

Last publish

Collaborators

  • rnssol
  • usmanfazil