diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index 0ffb4c3b35..83a8ca9c0e 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -687,7 +687,7 @@ export default class EthereumApi implements Api { */ @assertArgLength(1) async web3_sha3(data: DATA) { - return Data.from(keccak(Buffer.from(data))); + return Data.from(keccak(Data.from(data).toBuffer())); } //#endregion diff --git a/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts b/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts index 8ac8da5260..54b28f8da5 100644 --- a/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts @@ -19,12 +19,12 @@ describe("api", () => { }); it("web3_sha should hash the given input", async () => { - const input = "Tim is a swell guy."; - const result = await provider.send("web3_sha3", [input]); + const input = Buffer.from("hello world", "utf-8").toString("hex"); + const result = await provider.send("web3_sha3", [`0x${input}`]); assert.strictEqual( result, - "0xee80d4ac03202e2246d51a596c76a18e1a6d899bed9f05246d998fb656d9bd1f" + "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad" ); }); });