DEV Community

D
D

Posted on

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)