reef-relayer (EAS Delegation Worker)
Overview
- Cloudflare Worker that verifies EIP-712 delegated attestations and relays them to the EAS contract.
- Currently configured for Optimism Sepolia (chainId 11155420) and a specific schema UID.
Key files
- src/worker.ts: request handler, signature verification, relay call.
- wrangler.toml: Worker name and runtime variables.
- .dev.vars: local-only secrets for wrangler dev.
Runtime variables (wrangler.toml [vars])
- EAS_ADDRESS: EAS contract address on your network.
- SCHEMA_UID: Primary allowed schema UID.
- CHAIN_ID: Chain ID used if client domain.chainId is missing.
- ALLOWED_ORIGINS: Comma-separated list or "*".
- ALLOWED_SCHEMA_UIDS (optional): Comma-separated additional schema UIDs accepted during migration.
Secrets (wrangler secrets)
- RPC_URL: HTTPS RPC endpoint for the target network (e.g., Optimism Sepolia via Alchemy/Infura).
- RELAYER_PRIVATE_KEY: 0x-prefixed 32-byte hex private key for the relayer wallet.
Local development
- Install deps: pnpm install
- Set local secrets in .dev.vars (never commit real keys):
- RELAYER_PRIVATE_KEY=0x...
- RPC_URL=https://opt-sepolia.g.alchemy.com/v2/
- Run: pnpm wrangler dev
- GET http://127.0.0.1:8787 → { ok, eas, schema, chainId }
Deploy
- wrangler login
- wrangler secret put RPC_URL
- wrangler secret put RELAYER_PRIVATE_KEY
- pnpm wrangler deploy
- Verify: open your Worker URL → should show { ok, eas, schema, chainId }
POST endpoint (JSON) { "attester": "0x...", // signer address "delegatedAttestation": { // result from eas.getDelegated().signDelegatedAttestation() "domain": { "name":"EAS", "version":"1.x", "chainId":11155420, "verifyingContract":"0x..." }, "types": { ... }, "primaryType": "Attest", "message": { "schema": "0x...", // must match SCHEMA_UID or ALLOWED_SCHEMA_UIDS "recipient": "0x...", "expirationTime": 0, "revocable": true, "refUID": "0x00...00", "data": "0x...", // encoded payload "value": 0, "deadline": , "nonce": }, "signature": { "v": 27|28, "r": "0x...", "s": "0x..." } } }
Common errors
- SCHEMA_NOT_ALLOWED: The message.schema does not match SCHEMA_UID or ALLOWED_SCHEMA_UIDS. Check wrangler.toml and redeploy.
- BAD_NONCE: On-chain nonce (EAS.getNonce(attester)) does not match signed nonce. Re-query nonce and re-sign.
- DEADLINE_EXPIRED: deadline <= current time. Use a future deadline (e.g., now + 10 minutes).
- INVALID_SIGNATURE: EIP-712 signature check failed. Ensure domain.chainId and verifyingContract match the network/EAS address.
Renaming the repo to reef-relayer
- Git hosting (recommended): rename the repository in your hosting UI (GitHub → Settings → Repository name). Git will redirect remotes automatically.
- Local folder rename (optional):
- mv ../relayer ../reef-relayer
- Update any local scripts or paths that reference "relayer".
- If needed, update package.json name to "reef-relayer" (already safe to do).