I am using Avalanchejs a Javascript SDk to generate an address. After installing all dependencies and running the code. I get a new address, but the address shows up in a format. I tried to use the Buffer.from('xxx') method and then toString(). But it did not work. How can I convert the into a string ?
JS code:
const avalanche = require("avalanche")
const { Avalanche, BinTools, Buffer, BN } = require("avalanche")
const bintools = BinTools.getInstance()
const myNetworkID = 12345 //default is 1, we want to override that for our local network
const avalancheX = new Avalanche("localhost", 9650, "http", myNetworkID)
const xchain = avalancheX.XChain() //returns a reference to the X-Chain used by AvalancheJS
const myKeychain = xchain.keyChain()
const newAddress1 = myKeychain.makeKey()
console.log(newAddress1.pubk)
var buf = newAddress1.pubk;
console.log(buf.toString());
Terminal Output:
<Buffer 03 cd ab 4d e6 7d ee c5 9f c6 0d 27 e8 3b d2 da ee 84 ce f3 77 20 70 c9 8d 66 47 c7 36 91 ec 1f 07>
'�;������w pɍfG�6��