DEV Community

loading...

solidityとweb3のkeccak256について

dongri profile image D ・1 min read

Solidity側で以下のようにsha3

byte32 solidityMessage = keccak256(abi.encodePacked(address, msg.value, stringKey));

Web3では以下のように作成

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

検証

solidityMessage == web3Message

Discussion (0)

pic
Editor guide