Meta Tx - forward.verify returns false

This is a continuation question from Meta Tx - Forwarder fails to verify signature - #3 by barakman. I added latest block timestamp + 600 and still get false back when I call verify.

const EIP712DomainType = [
    { name: 'name', type: 'string' },
    { name: 'version', type: 'string' },
    { name: 'chainId', type: 'uint256' },
    { name: 'verifyingContract', type: 'address' }
  ]

  const ForwardRequestType = [
    { name: 'from', type: 'address' },
    { name: 'to', type: 'address' },
    { name: 'value', type: 'uint256' },
    { name: 'gas', type: 'uint256' },
    { name: 'nonce', type: 'uint256' },
    { name: 'data', type: 'bytes' }
  ]

const TypedData = {
    domain: {
      name: 'MinimalForwarder',
      version: '0.0.1',
      chainId: chainId,
      verifyingContract: '0x51C3354aC8143952Db46137947ED318299191803',
    },
    primaryType: 'ForwardRequest',
    types: {
      EIP712Domain: EIP712DomainType,
      ForwardRequest: ForwardRequestType
    },
    message: {
      request
    }
  };




{
  from: '0xB55A8bb04aF693823B0A00bF300b67a85BED6282',
  to: '0x6f776051Ce2d301b805b93eaD278A996A9674cbE',
  value: 0,
  chainId: 43113,
  deadline: 1706019735,
  gas: '25000000000',
  nonce: '0',
  data: '0xb4477c0147daecad546ef3fb323f46318050e87d0ee5144eb127e953e181dc59d409a762'
}

Which chain is that?

I'm looking at https://chainlist.org/, and the closest ones I see are:

  • Avalanche C-Chain, with chain-id 43114
  • Athereum, with chain-id 43110

this is avalanche testnet Fuji

So how come you ended up with this:

When the answer to your previous question has explicitly pointed you to this:

struct ForwardRequestData {
    address from;
    address to;
    uint256 value;
    uint256 gas;
    uint48 deadline;
    bytes data;
    bytes signature;
}

?

Should I remove chainId and nonce ?

  const request = {
    from: playerPubkey,
    to: unsignedProgram.address,
    value: 0,
    chainId,
    deadline: timestamp + 600, // valid for 10 minutes 
    gas: gas,
    nonce,
    data
  };

  const TypedData = {
    domain: {
      name: 'MinimalForwarder',
      version: '0.0.1',
      chainId: chainId,
      verifyingContract: '0x51C3354aC8143952Db46137947ED318299191803',
    },
    primaryType: 'ForwardRequest',
    types: {
      EIP712Domain: EIP712DomainType,
      ForwardRequest: ForwardRequestType
    },
  };

  const toSign = { ...TypedData, message: request };

  return Buffer.from(
    JSON.stringify(toSign), 
  ).toString('base64');

    const decodedTx = Buffer.from(transaction, "base64").toString("utf-8");
    const serializedTransaction = JSON.parse(decodedTx);

    const requestData = {
        ...serializedTransaction.message,
        signature: signature, 
    }

    const verify = await forwarderContract.verify(requestData);


Well, are they being used for anything else?

If no, then why have you added them to begin with?

If yes, then you should remove them only before you pass that object to the contract function.

Something like this would probably be the easiest to read and to understand:

const requestData = {
    from: serializedTransaction.message.from,
    to: serializedTransaction.message.to,
    value: serializedTransaction.message.value,
    gas: serializedTransaction.message.gas,
    deadline: serializedTransaction.message.deadline,
    data: serializedTransaction.message.data,
    signature: signature
};

const verify = await forwarderContract.verify(requestData);
1 Like

Still getting false after I deconstructed requestData.

Additional Info:

  • Worth to mention when I deployed my ERC2771Forwarder, I passed in name as LudexForwarder. Should this be used in the domain name currently set ''MinimalForwarder"?

Here is the target contract, you can see I'm trusting forwarder 0x51C3354aC8143952Db46137947ED318299191803 as the verifyingContract.