我将一个EIP_712签名从元请求发送到java后端(web3j),我需要在后端java应用程序上验证它。
在本主题中,将讨论java (Web3j)中对EIP-712的支持:
但是它没有任何文档或例子来说明如何去做!
发布于 2023-03-02 07:48:54
要通过web3验证签名,可以使用web3.eth.accounts.recover方法。我就是这么做的
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.');
}希望这对你有用
https://ethereum.stackexchange.com/questions/111429
复制相似问题