A simple on-chain voucher system with anonymous messaging and token claims. Issue vouchers under topics, share them with recipients, and let them redeem, post messages anonymously, or claim ERC20 tokens.
- Issue Vouchers: Create basic or binding vouchers under a topic. Only hashes are stored on-chain.
- Redeem Vouchers: Recipients submit the raw voucher to claim it.
- Anonymous Posting: Voucher holders can post messages to a bulletin board without revealing their identity (via ERC-4337).
- Claim Tokens: Binding voucher holders can claim ERC20 tokens to any address. The voucher's private key signs the recipient address to authorize the claim.
- Issue: Create vouchers under a topic (e.g., "event-2024"). Choose a use case (Post Message or Claim Token) and share the generated links with recipients.
- Redeem: Recipients visit the link and redeem their voucher on-chain.
- Post Message: Recipients can use their basic voucher to post an anonymous message. The message is stored as an on-chain event, and the poster's identity remains hidden.
- Claim Tokens: Recipients use a binding voucher's private key to claim ERC20 tokens. The private key signs the recipient address, ensuring only the intended recipient can claim.
SimpleVoucher intentionally stores only voucher hashes. Voucher type semantics are defined by how an application derives and redeems those hashes.
- Basic Voucher: A bearer secret. The issued hash is
keccak256(rawVoucher), and redemption reveals the raw voucher. This is simple and useful for anonymous flows, but on public blockchains it is vulnerable to transaction front-running once the raw voucher appears in calldata. - Binding Voucher: A single-use signing key. The issued hash is
keccak256(voucherSigner), and redemption proves possession of the corresponding private key by submitting a signature. The signed digest is application-defined, so apps can bind the voucher to a recipient, action, or other payload while keeping the core primitive general.
| Contract | Description |
|---|---|
SimpleVoucher |
Core voucher system - issue and redeem vouchers (basic and binding) |
VoucherBoard |
Anonymous bulletin board - post messages using vouchers via ERC-4337 |
DemoToken |
Simple ERC20 token with open mint for demo purposes |
TokenClaim |
Claim ERC20 tokens using binding vouchers |
-
Configure environment:
cp .env.example .env # Edit .env with your PRIVATE_KEY and RPC_URL -
Deploy SimpleVoucher:
forge script script/DeploySimpleVoucher.s.sol --rpc-url $RPC_URL --broadcast -
Deploy VoucherBoard (requires SimpleVoucher address):
# Add SIMPLE_VOUCHER_ADDRESS to .env first forge script script/DeployVoucherBoard.s.sol --rpc-url $RPC_URL --broadcast
-
Deploy DemoToken:
forge script script/DeployDemoToken.s.sol --rpc-url $RPC_URL --broadcast -
Deploy TokenClaim (requires SimpleVoucher and DemoToken addresses):
# Add DEMO_TOKEN_ADDRESS and CLAIM_AMOUNT to .env first forge script script/DeployTokenClaim.s.sol --rpc-url $RPC_URL --broadcast
See frontend/README.md for detailed setup instructions.
Quick start:
cd frontend
npm install
cp .env.example .env.local
# Edit .env.local with contract addresses and chain config
npm run dev# Install dependencies
forge install
# Build contracts
forge build
# Run tests
forge testMIT