I'm using web3js, and I'm trying to sign a tuple correctly.

Below you can see the solidity code for verification. I'm using draft-EIP712Upgradeable.sol

struct NFTVoucher {
    uint256 tokenId;
    uint256 minPrice; // in wei
    string uri;       // IPFS uri of metadata file
    bytes signature;  // the EIP-712 signature of all other fields in the NFTVoucher struct.

function _verify(NFTVoucher calldata voucher) public view returns (address) {
    bytes32 digest = _hash(voucher);
    return ECDSAUpgradeable.recover(digest, voucher.signature);

function _hash(NFTVoucher calldata voucher) internal view returns (bytes32) {
     return _hashTypedDataV4(keccak256(abi.encode(
         keccak256("NFTVoucher(uint256 tokenId,uint256 minPrice,string uri)"),

The frontend is built on ReactJs, web3js. The code you can find below 👇

let newHash = web3.utils.soliditySha3(

let sig = await web3.eth.sign(newHash, account); // "account" is the address of signer

So how should I change in the frontend code to pass the verification? If you need any other information please tell me. Any help is welcome. Thank youu!✌

Your Answer

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

Browse other questions tagged or ask your own question.