OpenZeppelin / workshops

Code and slides for OpenZeppelin Workshops
428 stars 277 forks source link

got "Error: call revert exception (method="getNonce(address)...." error when running "yarn sign" script #24

Closed said017 closed 1 year ago

said017 commented 1 year ago

Hi, I wonder why i got this error

Error: call revert exception (method="getNonce(address)", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.12)
    at Logger.makeError (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\logger\src.ts\index.ts:205:28)
    at Logger.throwError (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\logger\src.ts\index.ts:217:20)
    at Interface.decodeFunctionResult (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\abi\src.ts\interface.ts:326:23)
    at Contract.<anonymous> (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\contracts\src.ts\index.ts:309:44)
    at step (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\contracts\lib\index.js:46:23)
    at Object.next (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\contracts\lib\index.js:27:53)
    at fulfilled (D:\react-next-js\gasless\workshops\25-defender-metatx-api\node_modules\@ethersproject\contracts\lib\index.js:18:58)

Notes: I already make sure that Forwarder and Registry contract are deployed in Goerli and I call the contract with the deployed address (never run & test in local node for this project) so different network problem im pretty sure is eliminated.

It seems this function call is the cause of the error :

async function buildRequest(forwarder, input) {
  // console.log("go here?");
  // console.log(forwarder.address);
  // console.log(input.from);
  const nonce = await forwarder
    .getNonce(input.from)
    .then((nonce) => nonce.toString());
  return { value: 0, gas: 1e6, nonce, ...input };
}

Thanks before

said017 commented 1 year ago

for anyone having the same problem, I solved it by changing this line :

const request = await signMetaTxRequest(signer.provider, forwarder, { to, from, data });

to this line

  const request = await signMetaTxRequest(
    signer.provider,
    forwarder.connect(signer),
    {
      to,
      from,
      data,
    }
  );
sairarao112 commented 1 year ago

What should i do in sign.js class i wrote your solution but it wasn't working

vicentemunozlh commented 1 year ago

It worked for me and transactions pass successfully but nothing appears in the las registrations list ...