DEV Community

D
D

Posted on

1

solidityとweb3のkeccak256について

Solidity側で以下のようにsha3

byte32 solidityMessage = keccak256(abi.encodePacked(address, msg.value, stringKey));
Enter fullscreen mode Exit fullscreen mode

Web3では以下のように作成

const web3Message = Web3.utils.soliditySha3({t: 'address', v: address}, {t: 'uint', v: '123456'}, {t: 'string', v:'secret-key'});
Enter fullscreen mode Exit fullscreen mode

検証

solidityMessage == web3Message
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay