Created
January 29, 2021 09:02
-
-
Save cgcardona/a6dd267d1dcadbb5ddc57b623319dd07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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