boco-ledger
v1.0.0
Published
provide simple Ledger tooling for the Boco Ledger App with user friendly errors
Downloads
11
Maintainers
Readme
Boco Ledger App wrapper
This library helps interfacing with Boco Ledger App. It provides a developer friendly interface and user friendly error messages.
THANK YOU
This library is based on lunie-cosmos-js
by Juan Leni who implemented the Boco Ledger App. Thank you Juan!
Install
yarn add @bococoin/boco-ledger
Usage
Sign using the Ledger
import Ledger from "@bococoin/boco-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 Boco-js
import Ledger from "@bococoin/boco-ledger"
import Boco from "@lunie/Cosmos-js"
const privateKey = Buffer.from(...)
const publicKey = Buffer.from(...)
// init Boco sender
const Boco = Boco(STARGATE_URL, ADDRESS)
// create message
const msg = Boco
.MsgSend({toAddress: 'boco1abcd09876', amounts: [{ denom: 'ubcc', 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()