Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created January 29, 2021 09:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
import {
Avalanche,
BinTools,
Buffer
} from "avalanche"
import {
AVMAPI,
KeyChain,
KeyPair
} from "avalanche/dist/apis/avm"
const ip: string = 'localhost'
const port: number = 9650
const protocol: string = 'http'
const networkID: number = 12345
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const xchain: AVMAPI = avalanche.XChain()
const bintools: BinTools = BinTools.getInstance()
const xKeychain: KeyChain = xchain.keyChain()
const key: KeyPair = xKeychain.makeKey()
console.log(key.getAddressString())
const pubkey: Buffer = key.getPublicKey()
console.log(bintools.addressToString("local", "X", key.addressFromPublicKey(pubkey)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment