Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created December 23, 2020 15:55
Show Gist options
  • Save cgcardona/437918563af256a21594d2c7db75fbf8 to your computer and use it in GitHub Desktop.
Save cgcardona/437918563af256a21594d2c7db75fbf8 to your computer and use it in GitHub Desktop.
import { BinTools, Buffer } from "avalanche"
const bintools: BinTools = BinTools.getInstance()
const main = async (): Promise<any> => {
// hex private key exported from metamask
let hexPrivKey: string = "461109a6ffdd39be8eb7b763cb52b9cd7190c6e88ad35b7421dfb6f859ead495"
let buf: Buffer = Buffer.from(hexPrivKey, 'hex')
let encoded: string = `PrivateKey-${bintools.cb58Encode(buf)}`
console.log(encoded)
// cb58 encoded private key to import into our web wallet
// PrivateKey-XrkrRUWpsQ2ctH4D73vghLV1eSGnfp2CdspvvuBxQbHLzJttf
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment