This repository contains a solidity lib and helper scripts for providing claim code generation and on chain verification of a claim.
Reasons to use this lib over merkle proofs:
- No reliance on a pre generated list
- Uses EIP-712 ECDSA signing from an issuer private key
- A nearly-infinite number of claim codes can be generated
- No interactivity needed during the delivery of a claim code (could be printed)
- Secondary signing step to provide front running protection
Each claim code is a one-time-use private key and issuer EIP-712 valid ECDSA signature. The issuer signs the address matching the one-time-use private key. To provide frontrunning protection the user will then use the one-time-use private key to sign (potentially transparently with some nice ux) a destination address that will receive whatever is to be claimed.
Issuer signs one-time address off chain -> one-time signs claimant address off chain -> claimant receives with on-chain signature verification
By verifying that the secondary signer matches the address that is signed by the issuer you provide a chain of trust, protect against frontrunning, and allow the transaction sender to be an arbitrary address, no need to fund the one-time-use address.
Must have foundry and node installed and functioning
Install deps:
yarn
Build:
yarn build
Test:
forge test
set ISSUER_PRIVATE_KEY
and DEPLOYED_CLAIM_CONTRACT_ADDRESS
.
yarn generate-code
set claimCode
.
yarn prepare-tx
Licensed under the MIT license, see LICENSE
.