Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created January 29, 2021 09:02
Show Gist options
  • Save cgcardona/a6dd267d1dcadbb5ddc57b623319dd07 to your computer and use it in GitHub Desktop.
Save cgcardona/a6dd267d1dcadbb5ddc57b623319dd07 to your computer and use it in GitHub Desktop.
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