8

I am sending an EIP_712 signature from metamask to the java backend (web3j) and I need to verify it on backend java application.

In this topics it is discussed the support of EIP-712 in java (web3j):

but it does not have any documentation or example for how to do it!

1 Answer 1

0

To verify a signature via web3, you can use the web3.eth.accounts.recover method. Here's how I did it

const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/your-project-id'); // Replace with your own Infura project ID or URL

const signature = '...'; // Replace with the signature you want to verify
const message = '...'; // Replace with the original message that was signed
const address = '...'; // Replace with the expected signer address

const recoveredAddress = web3.eth.accounts.recover(message, signature);

if (recoveredAddress.toLowerCase() === address.toLowerCase()) {
  console.log('Signature is valid!');
} else {
  console.log('Signature is invalid.');
}

Hope that works for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.