Meta Tx - Forwarder fails to verify signature

I get this error when I call:

const serializedTransaction.message = {
 from: '0xB55A8bb04aF693823B0A00bF300b67a85BED6282',
 to: '0x6f776051Ce2d301b805b93eaD278A996A9674cbE',
 value: 0,
 gas: '25000000000',
 nonce: '0',
 data: '0xb4477c0147daecad546ef3fb323f46318050e87d0ee5144eb127e953e181dc59d409a762'
}
const verify = await forwarderContract.verify(serializedTransaction.message, signature);

Error:
"code":"UNEXPECTED_ARGUMENT","count":2,"expectedCount":1,"name":"Error","reason":"too many arguments: passed to contract"

not sure why it's throwing this error. Would appreciate any leads!

Thanks;

@ernestognw would be nice to get some eyes on this error. Please :smile:

This error-message implies that you are passing two input arguments to a function which takes only one input argument.

And indeed, function verify takes one input argument of type ForwardRequestData:

struct ForwardRequestData {
    address from;
    address to;
    uint256 value;
    uint256 gas;
    uint48 deadline;
    bytes data;
    bytes signature;
}
...
function verify(ForwardRequestData calldata request) public view virtual returns (bool) {
    ...
}

You should probably do something like:

const serializedTransaction = {
    from: '0xB55A8bb04aF693823B0A00bF300b67a85BED6282',
    to: '0x6f776051Ce2d301b805b93eaD278A996A9674cbE',
    value: 0,
    gas: '25000000000',
    deadline: deadline,
    data: '0xb4477c0147daecad546ef3fb323f46318050e87d0ee5144eb127e953e181dc59d409a762',
    signature: signature
}
const verify = await forwarderContract.verify(serializedTransaction);

Where deadline is a value equal to or larger than the timestamp of the current (latest) block.

2 Likes

Thanks for your answer. Do you know how can I specify a deadline in the correct format after verification in like 10 mins. ?

Use the timestamp of the current (latest) block, plus 600, which is the number of seconds in 10 minutes.

1 Like

jinks. But gg's appreciate your response.

Last question :grinning:;

I'm getting back false as a response for verify. Any hint why ? I'm using the same wallet that signed the EIP712. Domain name is the same that I deployed with the forwarder contract deployed.


  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 request = {
    from: playerPubkey,
    to: unsignedProgram.address,
    value: 0,
    chainId,
    deadline: 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
    },
    message: {
      request
    }
  };

I'm pretty sure that you should use the latest block timestamp plus 600 (and not just 600).

Other than that - you might wanna post this as a separate question (because, well, it is one).

1 Like