简体   繁体   中英

Web3: Extract data from soliditySha3

Let's say I call the following function to generate a hashed message for generating a signature.

function signMessage(recipient, amount, newNonce, contract, type) {
    const msgHash = web3.utils.soliditySha3(
        { t: "address", v: recipient },
        { t: "uint256", v: amount },
        { t: "string", v: newNonce },
        { t: "address", v: contract },
        { t: "uint256", v: type }
    ) || ""

    return web3.eth.accounts.sign(msgHash, privateKey);
}

On Solidity smart contract, how should I extract each information (for example, the "type") from that signature?

Turns out the hashed value is not reversable, but I can use the same variables to hash again on the smart contract and check if the two hashed values are the same, so I can know the value is transferred correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM