Skip to main content
Research Preview — Code snippets need testing against actual implementation.

Build a Location-Gated NFT

Create an NFT collection where minting requires passing a geospatial policy check — verifying the user is within range of a target location.
About location verification: This guide uses GPS coordinates as input. GPS is spoofable. We’re working on Location Proof plugins that will replace navigator.geolocation for stronger verification — these are still in development.

Overview

This guide walks through:
  1. Setting up a reference location
  2. Creating the resolver contract
  3. Building the frontend
  4. Handling the mint flow

Step 1: Set Up the Reference Location

First, create a location attestation for the target location. This could be a permanent landmark, or a dynamic location that changes.

Step 2: Deploy the Resolver Contract


Step 3: Register the Schema

Schema must use revocable: true — Astral signs delegated attestations with revocable: true. If your schema is registered with revocable: false, EAS will reject the attestation with an Irrevocable() or InvalidSignature() error.

Step 4: Frontend Integration

Location source: The navigator.geolocation API provides GPS coordinates which are spoofable. In production, replace with Location Proof plugins as they become available.

Step 5: React Component


Understanding inputRefs

The inputRefs array in policy attestations identifies the inputs used for the computation. The format depends on how inputs were provided:
If your contract checks inputRefs[1] == landmarkUID, it will only work when the landmark was passed as an attestation UID, not as raw GeoJSON. For raw GeoJSON, you’d need to compute the expected content hash.

Common Errors


Security Considerations

  1. Timestamp validation: Contract requires attestation < 1 hour old
  2. Replay prevention: Track used attestation UIDs
  3. Input verification: Check that the expected landmark was used
  4. One mint per address: Prevent farming

Next: Geofenced Token

Build a token with geographic restrictions