My current code snippet to create a KeyPair is
const nearLib = require("nearlib");
const keyRandom = nearLib.utils.KeyPairEd25519.fromRandom();
console.log(keyRandom);
console.log(keyRandom.getPublicKey());
My output for the public key of my KeyPair is
PublicKey {
keyType: 0,
data: Uint8Array [
86, 17, 27, 168, 244, 140, 239, 176,
142, 254, 255, 212, 141, 228, 99, 185,
50, 153, 127, 160, 174, 91, 203, 42,
84, 0, 187, 25, 6, 138, 241, 84
]
}
What on earth is this? Was expecting a base 58 public key, not a Uint8Array, I could probably cast it to base58? Unsure of exactly how to proceed here or why it is displaying in this way.
Just use .toString()
on the returned public key. Something like:
console.log(keyRandom.publicKey.toString());
That'll return key as base58 encoded string.