botdad / chain-claim

Claim code generation and on chain verification using EIP-712 instead of merkle proofs
MIT License
51 stars 2 forks source link

Chain Claim

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:

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.

Local build and test

Must have foundry and node installed and functioning

Install deps:

yarn

Build:

yarn build

Test:

forge test

Example scripts

Generate a claim code

set ISSUER_PRIVATE_KEY and DEPLOYED_CLAIM_CONTRACT_ADDRESS.

yarn generate-code

Prepare example transaction for claim

set claimCode.

yarn prepare-tx

Licensing

Licensed under the MIT license, see LICENSE.