"TypeError: EthCrypto.hash.Keccak256 is not a function" when doing Sign it like you mean it tutorial

Im getting TypeError: EthCrypto.hash.Keccak256 is not a function. right away

1 Like

Hi @Eric_Nickus,

Welcome to the community :wave:

What operating system, and versions of node and npm are you using?

I am using WSL2 (Windows Subsystem for Linux) on Windows 10, node v10.19.0 and npm 6.14.5.

I use the following script in my project directory:

signSomething.js

// signSomething.js
const EthCrypto = require("eth-crypto");
const signerIdentity = EthCrypto.createIdentity();
const message = EthCrypto.hash.keccak256([
  {type: "string",value: "Hello World!"}
]);
const signature = EthCrypto.sign(signerIdentity.privateKey, message);
console.log(`message: ${message}`);
console.log(`signature: ${signature}`);
console.log(`signer public key: ${signerIdentity.address}`);

I have installed eth-crypto

npm i eth-crypto

Output

$ node signSomething.js
message: 0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0
signature: 0xc897a47bde4af2394c5a78cfa1d78324ce12245bdf48ec3de8f59c50e3e695294456918bfe34db7a22c51746045f44c5578937c3af7d6ef00aae0dbf9d47257d1b
signer public key: 0x100fA05022c78C46268A018dCD7692aF71741601

It must have been my fault, now I can’t repeat the error and the code you provided here works like a charm.

Wondering if I should just delete this question or leave it , since it’s not really an issue with the library
?

Thanks very much

1 Like

Hi @Eric_Nickus,

Good to hear that you are up and running. :partying_face:

Leave the question, as if you had this problem, someone else may have it too.

All questions are good, as it improves the knowledge of the entire community.
Even when we can’t reproduce the error. :smile: