Thanks to visit codestin.com
Credit goes to github.com

Skip to content

howardengine/eventshield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EventShield: Cryptographic Ticketing & Anti-Scalping Protocol on Arc L1

EventShield Banner

EventShield is a decentralized, secure event ticketing marketplace and dynamic anti-scalping protocol built natively on the Arc Network (Chain ID: 5042002). By hardcoding commerce guidelines directly within Solidity EVM primitives, implementing EIP-712 dynamic ticket check-in signatures, and leveraging Circle’s USDC for gasless settle speeds, EventShield prevents bot manipulation, secures ticket payouts, and routes secondary royalties directly to artists.

Important

Arc L1 Network Advantages: EventShield utilizes Arc Network, where native USDC acts as the gas token. This enables fee predictability and native stablecoin settlement. With EventShield's custom Gas Station / /api/sponsor API, end-users experience a completely gasless interface sponsored via Circle Developer APIs.


1. Core Thesis & Protocol Vision

Traditional event ticketing frameworks are plagued by systemic inefficiencies. Secondary markets are dominated by automated bots that drain primary allocations, inflate ticket resale prices, and leave artists out of secondary trade revenues. At the same time, visual-only QR ticket entry systems are prone to copy-paste screenshot theft and replay exploits.

EventShield shifts the ticketing trust model from off-chain database logic to immutable on-chain enforcement:

  • Hardcoded Resale Caps: Resale listings are restricted at the contract level to originalPrice * (100 + maxMarkupPercentage) / 100. Listing attempts above this limit fail during the EVM transaction phase.
  • On-Chain Artist Royalties: 10% secondary sales royalties are routed to creator wallets atomically within the same purchase transaction.
  • EIP-712 Cryptographic Gate Admission: To block screenshot duplication, checkpoints recover dynamic private signatures generated locally by the holder's wallet.
  • Unified Multi-Chain stablecoin liquidity: Fans refuel their ticketing wallets using Circle Unified Balance and CCTP Bridge kits from Base, Ethereum, and Avalanche, and convert EURC to USDC via StableFX.

2. Technical Architecture & Protocol Topologies

The EventShield architecture divides protocol responsibilities among four specialized Solidity contracts deployed on the Arc Testnet:

                              ┌────────────────────────────────────────┐
                              │          EventTicket (ERC-721)         │
                              │  - Primary and secondary sales logic   │
                              │  - Markup caps & 10% secondary royalty │
                              │  - EIP-712 check-in recovery verification│
                              └──────────┬──────────┬──────────┬───────┘
                                         │          │          │
                     checks/registers    │          │          │  mints commemorative
                     attendance count    ▼          │          ▼  NFTs upon check-in
            ┌──────────────────────────────┐        │    ┌──────────────────────────────┐
            │      FanRewardRegistry       │        │    │       EventCollectible       │
            │ - Attendance tracking        │        │    │ - On-chain base64 NFT drops  │
            │ - 20-200 USDC cashbacks      │        │    │ - Platinum special editions  │
            │ - Gold+ 24h early access     │        │    └──────────────────────────────┘
            └──────────────────────────────┘        │
                                                    ▼
                                     ┌──────────────────────────────┐
                                     │       ReferralRegistry       │
                                     │ - Affiliate relationships    │
                                     │ - 2% USDC platform fee splits│
                                     │ - 5 USDC milestone bonuses   │
                                     └──────────────────────────────┘

System Design Rationale & Tradeoffs

  1. USDC Native Gas: Using Arc Network where USDC is the native gas asset avoids complex gas-token bridging UX.
  2. Double-Spend & Escrow Protection: All primary purchases can escrow funds based on RefundPolicy (Full, Partial, or No Refund). If an event is cancelled, fans claim refunds which automatically claw back referrer commissions via the ReferralRegistry.
  3. Optimized Gate Scans: Scanners parse and verify signatures offline before submitting the on-chain sponsored transaction, minimizing chain load.

3. Token Commerce & Entry Lifecycle

The flowchart below demonstrates the transaction and state transitions when minting, listing, reselling, verifying, and claiming reward payouts:

graph TD
    classDef default fill:#121214,stroke:#fff,stroke-width:1px,color:#fff;
    classDef contract fill:#1a1a1f,stroke:#fff,stroke-dasharray: 5 5,color:#fff;
    
    A[Creator / Organizer] -->|Register Event| B(EventTicket Contract)
    C[True Fan] -->|Purchase Ticket with USDC| B
    
    C -->|List Ticket on Resale| D{Price Validation}
    D -->|Asked Price <= Cap| E[Approved Resale Listing]
    D -->|Asked Price > Cap| F[Transaction Reverted]
    
    G[Secondary Buyer] -->|Purchase Listed Resale| E
    E -->|89% Payout| C
    E -->|10% Artist Royalty| A
    E -->|1% Safety Fee| B
    E -->|Transfer NFT| G
    
    G -->|Generate EIP-712 QR Code| H(Gate Agent Scanner)
    H -->|Validate Timestamp & Nonce| I{Cryptographic ecrecover?}
    I -->|Valid Signature| J[Mark Ticket Used]
    I -->|Invalid Signature| K[Access Denied]
    
    J -->|Register Attendance| L(FanRewardRegistry)
    L -->|Trigger NFT Commemoration| M(EventCollectible Mint)
    L -->|Attended >= 3 Shows| N[Claim USDC Cashback Bounty]
    
    class B,L,M,ReferralRegistry contract;
Loading

4. Circle Wallet & Stablecoin Stack Integration

EventShield features deep, production-grade integrations with the Circle developer and stablecoin suites:

A. Circle W3S User-Controlled Wallets (Web SDK)

EventShield integrates the @circle-fin/w3s-pw-web-sdk to provision secure, non-custodial Smart Contract Accounts (SCA) for users. Users onboard via social auth, configure a recovery PIN, and sign transactions.

  • Frontend Context: CircleWalletContext.tsx handles device ID initialization, PIN creation challenges, and session renewals.
  • EIP-712 Signing: Used to sign EIP-712 ticket validation hashes locally, bypassing standard gas requirements.

B. Circle Developer-Controlled Wallets

  • Organizers reserve payouts: Autonomous payouts are executed from the developer-controlled organizer wallet (CIRCLE_ORGANIZER_WALLET_ID) using the @circle-fin/developer-controlled-wallets SDK.
  • Bounty Claims: Eligible fans claiming cashbacks from FanRewardRegistry receive automatic on-chain USDC payouts sponsored by the organizer.

C. Circle Gas Station & Transaction Sponsorship

To provide a completely gasless experience, all write operations (purchases, listings, check-ins, claims) route through a Next.js API proxy (/api/sponsor) that interacts with Circle Programmable Wallets to sponsor gas.

Warning

Sponsorship Security Controls:

  1. Whitelist Filtering: Sponsoring is restricted strictly to the 4 whitelisted EventShield contract addresses and 9 specific function signatures.
  2. USDC Approve Restrictions: If the call is approve(address,uint256) on the USDC contract, the spender address must be the EventTicket contract. Users cannot exploit the Gas Station to approve external drainers.
  3. Rate Limiting: Wallets are rate-limited to 10 sponsored transactions per hour.
// Core implementation from frontend/src/app/api/sponsor/route.ts
const response = await circleClient.createUserTransactionContractExecutionChallenge({
  userToken,
  walletId,
  contractAddress,
  abiFunctionSignature,
  abiParameters: abiParameters || [],
  fee: { type: 'level', config: { feeLevel: 'MEDIUM' } },
});

D. Circle Unified Balance Kit (@circle-fin/app-kit)

Fans can spend USDC residing on other chains without manually bridging first. The frontend incorporates useUnifiedBalance to query balances across Base Sepolia, Ethereum Sepolia, Avalanche Fuji, and Arc Testnet, and executes direct ticket purchases:

const result = await appKit.unifiedBalance.spend({
  from: { adapter },
  to: { recipientAddress: destAccount, chain: 'Arc_Testnet', useForwarder: true },
  amount,
  token: 'USDC'
});

E. Circle Bridge Kit & CCTP Refilling

For manual balance management, CircleBridgeKit.tsx provides an interface to execute CCTP native burn-and-mint transfers. It includes a cryptographic debugger displaying the burn hash, source/destination domain IDs, and Circle Attestation API requests (https://iris-api-sandbox.circle.com/v1/attestations/...).

F. StableFX RFQ & Permit2 Conversion

EventShield supports converting EURC (Euro stablecoin) to USDC using Circle's StableFX API and the Permit2 verifying contract (0x000000000022D473030F116dDEE9F6B43aC78BA3). Users sign a PermitWitnessTransferFrom message to execute EURC conversions atomically:

const quoteSignature = await signTypedDataAsync({
  domain: quote.typedData.domain,
  types: quote.typedData.types,
  primaryType: quote.typedData.primaryType,
  message: quote.typedData.message
});

5. Autonomous AI Swarm Workflows (ERC-8004 Agent Framework)

EventShield implements an on-chain AI agentic swarm using the ERC-8004 standard for Agent Identity, Reputation, and Validation Registries. The swarm consists of 4 agents managed by the CopilotPanel chatbot interface:

                      ┌────────────────────────────────────┐
                      │ MasterAgent (Orchestration Router) │
                      └─────────────────┬──────────────────┘
                                        │
             ┌──────────────────────────┼──────────────────────────┐
             ▼                          ▼                          ▼
┌────────────────────────┐  ┌────────────────────────┐  ┌────────────────────────┐
│        OpsAgent        │  │       LoyalAgent       │  │       GuardAgent       │
│ - Configures payloads  │  │ - Payouts USDC cashbacks│  │ - Verifies gate ticket │
│ - Reads contract states│  │ - Circle dev-wallets   │  │   signatures (EIP-712) │
└────────────────────────┘  └────────────────────────┘  └────────────────────────┘
  1. MasterAgent (Orchestration Router): Routes user prompts to the correct sub-agent.
  2. OpsAgent (Dynamic Event Configurator):
    • Configures deployment parameters for new events (prices, markup caps, dates).
    • Automatically reads the next event ID from the on-chain ticket registry.
  3. LoyalAgent (Loyalty & Payout Automation):
    • Queries FanRewardRegistry on-chain to verify check-in requirements.
    • Triggers the Developer-Controlled Wallet API to payout USDC cashbacks to eligible fans.
  4. GuardAgent (Anti-Scalp & Signature Protection):
    • Queries EventTicket ticket mappings on-chain.
    • Inspects ticket state, seat, and check-in statuses.

On-Chain ERC-8004 Registry Setup

The EventShield Gatekeeper Agent is registered on the Arc Testnet with Agent ID 800401 under the following ERC-8004 contract addresses:

  • Identity Registry: 0x8004A818BFB912233c491871b3d84c89A494BD9e (NFT registration with IPFS metadata URI)
  • Reputation Registry: 0x8004B663056A597Dffe9eCcC1965A193B7388713 (Validator feedback score: 98/100)
  • Validation Registry: 0x8004Cb1BF31DAf7788923b405b754f57acEB4272 (KYC verification status: kyc_verified)

6. Cryptographic Gate Entry Mechanism

To prevent screenshot replication, ticket entry codes expire after 15 seconds. The ticket holder's client wallet generates a signature based on EIP-712 structured data:

EIP-712 Schema Definition

bytes32 public constant CHECKIN_TYPEHASH = keccak256(
    "CheckInRequest(uint256 tokenId,address owner,uint256 timestamp,uint256 nonce)"
);

Signature Generation & Verification Flow

  1. Nonce Check: The client queries the current check-in nonce checkInNonces[owner] from EventTicket.
  2. Timestamping: The client signs the hash using a current UNIX timestamp.
  3. QR Construction: The client encodes the signature, tokenId, owner address, timestamp, and nonce into a dynamic QR code.
  4. Scanner Validation:
    • The scanner parses the QR code.
    • It checks: block.timestamp - timestamp <= 90 seconds (prevents old screenshot playback).
    • It checks: timestamp <= block.timestamp + 30 seconds (allows minor clock drift).
    • It executes ecrecover on-chain or off-chain to verify the signer matches the ticket owner.
    • The transaction is sent to checkInTicket, incrementing the owner's nonce to prevent replay attacks.

7. Smart Contract Registry & Explorers

Both contracts are compiled using Solidity 0.8.20 with EVM Shanghai settings and are verified on Arc Testnet:

Contract Name Arc Testnet Address Blockchain Explorer link
EventTicket (ERC-721) 0x47e9dfBB189601B0FE25c26d75a11C266b22E82D View on ArcScan
FanRewardRegistry 0x49a7192C113c46923c542D406a956c31c6D5c677 View on ArcScan
ReferralRegistry 0xB04cb31DAF7788923b405B754F57acEB4272113C View on ArcScan
EventCollectible (NFT) 0xbc8F266A48F95F319D72a8004B663056A597Dffe View on ArcScan
Native USDC Gas Token 0x3600000000000000000000000000000000000000 View on ArcScan

8. Protocol Capabilities & On-Chain Mechanics

Function Signature Scope Core Protocol Rules
createEvent(CreateEventParams params) Event Launch Configures price, seat limit, refund policy, and markup cap (Max royalty capped at 50%)
purchasePrimaryTicket(eventId, seatNo) Primary Sale Mints ticket, applies loyalty discounts (Silver 5%, Gold 10%, Platinum 15%), and tracks referral commission (2%)
listTicketForResell(tokenId, askedPrice) Resale Validates requested price against markup cap; reverts if price is exceeded
buyResellTicket(tokenId) Resale Atomically transfers NFT, distributes 10% royalty to artist, 1% fee, and seller portion
checkInTicket(tokenId, owner, timestamp, signature) Gate Entry Cryptographically verifies owner signature, enforces 90s time window, registers attendance, and mints NFT
claimLoyaltyReward() Cashback Distributes 20 USDC to fans with 3+ check-ins (Bronze tier)
claimTierReward(tier) Multi-tier claims Claims cashbacks for higher tiers (Silver: 50 USDC, Gold: 100 USDC, Platinum: 200 USDC)
claimCommissions() Referrals Claims accrued affiliate referral commissions from ReferralRegistry

9. Backend API & Interface Specifications

1. Circle Wallet Authentication Proxy (/api/circle-auth)

Handles backend user and wallet creation inside the Circle developer dashboard.

  • Actions: init-session (Generates user tokens/encryption keys), init-wallet (Launches PIN challenge), execute-contract (Standard contract write payload), sign-typed-data (Generates signatures), get-latest-tx (Queries transaction hashes).

Request Example (Initialize Session):

{
  "action": "init-session",
  "email": "[email protected]"
}

Response Example:

{
  "success": true,
  "userId": "fan_fan_eventshield_io",
  "userToken": "eyJhbGciOi...",
  "encryptionKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...",
  "hasWallet": true,
  "walletAddress": "0x6fB123893a74F2Cc117E3d0e98EC3A92A69A1234",
  "walletId": "b8a82d0b-6a51-55c1-83d6-b927e4054050"
}

2. Gas Sponsorship Engine (/api/sponsor)

Coordinates Gas Station sponsorships for whitelisted actions.

  • Actions: GET (Retrieves sponsor analytics), POST (Sponsors a smart contract write or deposits funding).

Request Example (Sponsor primary purchase):

{
  "userToken": "eyJhbGciOi...",
  "walletId": "b8a82d0b-6a51-55c1-83d6-b927e4054050",
  "contractAddress": "0x47e9dfBB189601B0FE25c26d75a11C266b22E82D",
  "abiFunctionSignature": "purchasePrimaryTicket(uint256,string)",
  "abiParameters": ["1", "Seat A12"]
}

Response Example:

{
  "success": true,
  "challengeId": "a90b8c6d-927e-4050-b55c-1c229255a6d2",
  "isGasSponsored": true,
  "analytics": {
    "totalSponsoredTxCount": 104,
    "totalGasSponsoredUSDC": 0.52,
    "treasuryBalance": 249.48,
    "functionCalls": {
      "purchasePrimaryTicket(uint256,string)": 42
    }
  }
}

3. AI Swarm Command Router (/api/agent/command)

Coordinates NLP commands to the specialized agentic swarm.

Request Example (Get Audit status from GuardAgent):

{
  "command": "verify signature of ticket #12",
  "address": "0x6fB123893a74F2Cc117E3d0e98EC3A92A69A1234"
}

Response Example:

{
  "success": true,
  "agent": "GuardAgent (Anti-Scalp & Signature Protection)",
  "response": "GuardAgent has verified Ticket #12 on the Arc L1 blockchain. The ticket is currently active and unused, assigned to Seat \"Seat A12\", with a secondary markup resell cap of +20% strictly enforced.",
  "steps": [
    "[GuardAgent] Connecting to ticket registry contract...",
    "[GuardAgent] Querying contract mapping at address: 0x47e9dfBB189601B0FE25c26d75a11C266b22E82D",
    "[GuardAgent] Target Token ID resolved: 12",
    "[GuardAgent] Ticket details fetched -> Event ID: 1 | Original Price: 20 USDC | Cap: 20% | Seat: Seat A12",
    "[GuardAgent] Gate Entry Status: ACTIVE (UNUSED)"
  ],
  "actionResult": {
    "status": "VERIFIED",
    "ticketId": "12",
    "eventId": "1",
    "originalPrice": "20 USDC",
    "maxMarkupPercent": "20",
    "artistWallet": "0xbc8F266A48F95F319D72a8004B663056A597Dffe",
    "isUsed": false,
    "seatNumber": "Seat A12"
  },
  "agentId": "800401",
  "timestamp": "2026-07-01T07:42:07.123Z"
}

10. Local Sandbox Setup & Onboarding

Local Environment Prerequisites

  • Node.js (v18.x or greater)
  • Hardhat framework tools

1. Smart Contract Compilation & Deployment

Navigate to the contracts directory, install dev packages, and execute the deployer script:

cd contracts
npm install
npm run compile
npm run deploy

The deploy script compiles all solidity contracts, launches them onto the Arc network, links registry addresses, and updates frontend ABIs and addresses in frontend/src/lib/constants.ts automatically.

To register the AI Gatekeeper Agent under the ERC-8004 standard on-chain, run:

node scripts/register-agent.mjs

2. Launching the Web Portal

Configure environment variables in frontend/.env.local:

NEXT_PUBLIC_CIRCLE_APP_ID=b75a0a0f-07b0-5422-abc8-f309252d8cb0
NEXT_PUBLIC_CIRCLE_CLIENT_KEY=TEST_CLIENT_KEY:...
NEXT_PUBLIC_CIRCLE_CLIENT_URL=https://modular-sdk.circle.com/v1/rpc/w3s/buidl
CIRCLE_API_KEY=TEST_API_KEY:...
CIRCLE_ENTITY_SECRET=27272eee7b9b055e00affc54a2c994f695e58117cb93afeb6864f8da4b021ec4
CIRCLE_ORGANIZER_WALLET_ID=e1cb7936-4a51-55c1-83d6-b927e4054050

Start the Next.js development server:

cd ../frontend
npm install
npm run dev

Navigate to http://localhost:3000 to interact with the platform.

About

EventShield is a decentralized event ticketing marketplace and dynamic anti-scalping protocol running natively on the Arc Network. By hardcoding commerce policies directly inside Ethereum Virtual Machine (EVM) primitives and utilising Circle's USDC for gasless settle speeds, EventShield prevents bot manipulation, secures ticket payouts, and routes

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors