Categories
Cryptocurrency Ethereum Mastering Development

transfer hash verification on contract side

I want to verify if message-hash has a particular contract method.

Like below web3 code generates a rawTransaction having,messageHash,v, r, s, rawTransaction

let rawTransaction = {
        'from': fromAddress,
        'gasLimit': web3js.utils.toHex(310000),
        'to': contractAddress,
        'gasPrice': web3js.utils.toHex(20 * 1e9),
        'value': "0x0",
        'data': contract.methods.transfer(toAddress, amount).encodeABI(),
        'nonce': web3js.utils.toHex(count),
    }
  web3js.eth.accounts.signTransaction(rawTransaction, PK);

i.e if message hash from the above signed transaction is “0x9de6f7321d6374c8e26a1cd043daa71719175af97ed0f098260bf117db48dcbf”

How can I create same hash in contract by passing above data for verification that given transaction hash is for transfer with all given values?

I have tried keccak256(abi.encodePacked()) using above data but it is generating different hash, may be I am doing something wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *