Estoy usando Avalanchejs un Javascript SDk para generar una dirección. Después de instalar todas las dependencias y ejecutar el código. Obtengo una nueva dirección, pero la dirección aparece en un formato. Traté de usar el método Buffer.from('xxx') y luego toString(). Pero no funcionó. ¿Cómo puedo convertir el en una cadena?
Código JS:
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());Salida terminal:
<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��