diff --git a/web3.js/src/publickey.ts b/web3.js/src/publickey.ts index 449f90371f5fc8..4d17ae68ca9c05 100644 --- a/web3.js/src/publickey.ts +++ b/web3.js/src/publickey.ts @@ -112,7 +112,8 @@ export class PublicKey extends Struct { * Return the byte array representation of the public key in big endian */ toBytes(): Uint8Array { - return this.toBuffer(); + const buf = this.toBuffer(); + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); } /**