botdad / chain-claim

Claim code generation and on chain verification using EIP-712 instead of merkle proofs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • 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.

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.

About

Claim code generation and on chain verification using EIP-712 instead of merkle proofs

License:MIT License


Languages

Language:Solidity 82.4%Language:TypeScript 17.6%