EIP1271 Module
A simple library to validate EIP1271 signatures.
Usage
Simple usage
import ethers from "ethers";
import {
isValidEip1271Signature,
isValidEip1271SignatureForAllNetworks,
} from "@etherspot/eip1271-verification-util";
import { MNEMONIC, RPC } from "./constants";
const checkSig = async () => {
const signer = ethers.Wallet.fromMnemonic(MNEMONIC);
const data = "0x123456";
const rpcUrls = [RPC.polygon, RPC.bsc, RPC.xdai];
const walletAddress = signer.address;
const signature = await signer.signMessage(ethers.utils.arrayify(hexxed));
const hash = ethers.utils.hashMessage(ethers.utils.arrayify(hexxed));
const isValidSig = await isValidEip1271Signature(
rpcUrls,
walletAddress,
hash,
signature
);
console.log("is signature valid:", isValidSig);
const isValidSigPerNetwork = await isValidEip1271SignatureForAllNetworks(
rpcUrls,
walletAddress,
hash,
signature
);
console.log("is signature valid for each network:", isValidSigPerNetwork);
};