Skip to content

Library for interacting with the Color Ledger Nano app 🔌

Notifications You must be signed in to change notification settings

GenesisLabs-com/color-ledger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color Ledger App wrapper

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

THANK YOU

This library is based on ledger-Color-js by Juan Leni who implemented the Color Ledger App. Thank you Juan!

Install

yarn add @colorplatform/color-ledger

Usage

Sign using the Ledger

import Ledger from "@colorplatform/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 Color-js

import Ledger from "@colorplatform/color-ledger"
import Color from "@lunie/Cosmos-js"

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

// init Color sender
const Color = Color(STARGATE_URL, ADDRESS)

// create message
const msg = Color
  .MsgSend({toAddress: 'Color1abcd09876', amounts: [{ denom: 'stake', 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()

About

Library for interacting with the Color Ledger Nano app 🔌

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.8%
  • JavaScript 4.2%