Skip to main content
GatePass Smart Contracts

Introduction

GatePass uses a modular smart contract system built on Solidity 0.8.24 and deployed on Polygon for fast, low-cost transactions. The architecture consists of three main contracts that work together to provide a complete event ticketing solution.

EventTicketFactory

Deploys event contracts using minimal proxy clones for gas efficiency

EventTicket

ERC721 NFT tickets with sales, check-in, and access control

ProofOfAttendance

Soulbound ERC721 NFTs minted upon event check-in

Contract Architecture

The GatePass smart contract system follows a factory pattern with minimal proxy clones to optimize gas costs for event organizers.

Factory Pattern

The EventTicketFactory uses OpenZeppelin’s Clones library to deploy minimal proxy contracts, reducing deployment costs by ~90% compared to deploying full contracts.
Minimal proxies (EIP-1167) are lightweight contracts that delegate all calls to an implementation contract. This means:
  • Lower gas costs: Deployment costs ~12insteadof 1-2 instead of ~20-30
  • Consistent implementation: All events use the same audited code
  • Upgradeable pattern: Factory can deploy new versions while keeping old events functional

Key Features

Ticket Sales

  • ERC721 NFT tickets with configurable supply and pricing
  • Time-gated sales with customizable start and end times
  • Wallet limits to prevent scalping (default: 5 tickets per wallet)
  • Allowlist support using Merkle proofs for presales
  • Automatic refunds for excess payment

Check-In System

  • Self check-in: Ticket holders can check themselves in after event starts
  • Organizer check-in: Event organizers can assist with check-in
  • Single-use tickets: Tickets are marked as used to prevent double entry
  • POA minting: Proof of Attendance NFTs automatically minted on check-in

Revenue Management

  • Platform fees: Configurable fee (default 2.5%) collected by GatePass
  • Delayed withdrawal: Organizers can withdraw funds only after event date
  • Automatic fee distribution: Platform fees and organizer revenue split automatically

Security Features

  • ReentrancyGuard: Protection against reentrancy attacks
  • Pausable: Emergency pause functionality for organizers
  • Ownable: Access control for critical functions
  • MerkleProof verification: Secure allowlist implementation

Network Deployment

GatePass contracts are currently deployed on Polygon mainnet for production use.

Polygon Configuration

const POLYGON_CONFIG = {
  chainId: 137,
  rpcUrl: 'https://polygon-rpc.com',
  factoryAddress: '0x...', // Deployed factory address
  blockExplorer: 'https://polygonscan.com'
};

Why Polygon?

Polygon transactions cost fractions of a cent, making it affordable for both organizers and attendees to mint tickets and check in.
~2 second block times mean instant ticket minting and check-in confirmations.
Full Ethereum compatibility means easy integration with existing tools and wallets like MetaMask.
Polygon has robust infrastructure, block explorers, and developer tools.

Contract Interactions

Creating an Event

// 1. Organizer calls factory
address eventContract = factory.createEvent(
    "My Concert",           // eventName
    "CONCERT",              // eventSymbol
    1000,                   // totalSupply
    0.01 ether,            // ticketPrice
    block.timestamp,        // saleStart
    block.timestamp + 7 days,  // saleEnd
    block.timestamp + 14 days, // eventDate
    "https://api.example.com/metadata/" // baseTokenURI
);

// 2. Factory deploys minimal proxy clone of EventTicket
// 3. EventTicket initializes and deploys ProofOfAttendance

Ticket Purchase Flow

// 1. Attendee mints ticket(s)
eventTicket.mint{value: 0.03 ether}(3);

// 2. Contract verifies:
//    - Sale is active (between saleStart and saleEnd)
//    - Supply is available
//    - Payment is sufficient
//    - Wallet limit not exceeded

// 3. Tickets are minted as ERC721 NFTs
// 4. Excess payment is refunded

Check-In Flow

// After event starts (eventDate), attendee checks in:
eventTicket.checkIn(tokenId);

// 1. Verifies ticket ownership
// 2. Marks ticket as used
// 3. Mints Proof of Attendance NFT to attendee
// 4. Emits check-in events

OpenZeppelin Dependencies

GatePass contracts are built on audited OpenZeppelin libraries:
  • ERC721: Standard NFT implementation
  • ERC721Enumerable: Enable token enumeration
  • Ownable: Access control
  • ReentrancyGuard: Reentrancy protection
  • Pausable: Emergency stop mechanism
  • MerkleProof: Allowlist verification
  • Clones: Minimal proxy pattern

Gas Optimization

The contracts implement several gas optimization techniques:
1

Minimal Proxies

Using EIP-1167 clones reduces deployment costs by ~90%
2

Storage Packing

Related variables are grouped to minimize storage slots
3

Custom Errors

Using custom errors instead of require strings saves gas
4

Batch Operations

Mint multiple tickets in a single transaction

Next Steps

Deploy Contracts

Learn how to deploy the contract system

EventTicket Reference

Detailed documentation of the EventTicket contract

Factory Reference

Learn about the factory pattern implementation

POA Reference

Documentation for Proof of Attendance NFTs

Build docs developers (and LLMs) love