I'm trying to hash a message as shown here:

function constructPaymentMessage(contractAddress, amount) {
  return ethereumjs.ABI.soliditySHA3(
    ["address", "uint256"],
    [contractAddress, amount],

how can I use web3.sha3 instead of ABI.soliditySHA3 to get the SHA3 hash correctly, is there any difference anyway? thanks.


Here maybe this will help https://web3js.readthedocs.io/en/1.0/web3-utils.html#soliditysha3


This is actually implemented in ethereumjs-abi:

var abi = require('ethereumjs-abi')
var BN = require('bn.js')

    [ "address", "address", "uint", "uint" ],
    [ new BN("43989fb883ba8111221e89123897538475893837", 16), 0, 10000, 1448075779 ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.