Search code examples
node.jsblockchainethereumsolidityethers.js

The method eth_signTypedData_v4 does not exist/is not available


Showing an error while calling solidity contract, which is deployed already in rinkeby-infura. I am using ethers.js inside my React app. I've seen similar issues like this but I am not simply trying to send a transaction but rather trying to sign a type data as explained here. And I am calling it almost the same:

const signature = await mySigner._signTypedData(domain, types, voucher)

What am I missing?


Solution

  • What I was doing had the almost same issue as the example question I provided. I was trying to sign a typed data. This used to be working in my Hardhat project and from what I understand the hardhat was interrupting the call and using my private key which was provided inside the hardhat.config.js file. How do I resolve this issue?

    Instead of using regular JSONRpcProvider, I started using injectedProvider. I've found an example here: https://docs.scaffoldeth.io/scaffold-eth/examples-branches/common-web3-patterns/signator.io

    The injectedProvider was also present inside the example project that I am using (here). But for some reason it was exist inside the App.jsx but never send (or used) to the Minter.jsx. I've added the injectedProvider to the mintNFT class and get the signer from there with const mySigner = injectedProvider.getSigner(). After that I was able to successfully sign the typed data with await mySigner._signTypedData(domain, types, voucher). This opened a nice pop-up in my MetaMask wallet and I signed the message.