is-valid-signature
Check if a signature is valid for an Ethereum address. Works for both externally owned accounts and contract accounts that follow the ERC1271 standard.
Install
npm install is-valid-signature
Getting started
Check signatures for externally owned accounts
const isValidSignature = const signer = YOUR_SIGNER_ADDRESS // Get a signatureconst message = web3utilsconst signature = await web3eth // Check if the signature is validconst isValid = await
Check signatures for ERC-1271 contracts
const isValidSignature = const signer = YOUR_SIGNER_ADDRESS // Get contract where `signer` can sign on behalf of contractconst contract = ERC1271 // Get a signatureconst message = web3utilsconst signature = await web3eth // Check if the signature is validconst isValid = await
ERC-1271
ERC-1271 is currently a draft and there are multiple proposed interfaces. This package supports the following ERC-1271 interface.
contract ERC1271 {
function isValidSignature(
bytes memory _messageHash,
bytes memory _signature)
public
view
returns (bytes4 magicValue);
}
Test
npm test