npm i
# Test signature verification(generate Hash onchain)
npx hardhat test test/verify-signature.js
# Test signature2 verification(generate Hash offchain)
npx hardhat test test/verify-signature2.js
# Test ERC20 Permit
npx hardhat test test/erc20-permit.js
- EIP-712: Typed structured data hashing and signing
- EIP-2612: permit – 712-signed approvals
- https://eips.ethereum.org/EIPS/eip-191
stage | details | ethers.js |
---|---|---|
initial | encode(Tx: T) = RLP_encode(Tx) | |
normal | encode(message) = "\x19Ethereum Signed Message:\n" || len(message)||message | signer.sigMessage(hash) |
EIP-712 | encode(domainSeparator, message) = "\x19\x01"||domainSeparator||hashStruct(message) | signer._signTypeData() |
EIP-2612 | special case for EIP-712 |