Back to Docs

NornGate

Contract

Content gating with one-time unlock payments. Sell exclusive content, downloads, or access to premium resources.

Overview

The NornGate contract allows creators to gate content behind a one-time payment. Once unlocked, users have permanent access. Content is identified by a bytes32 content ID that you define.

One-Time Payments

Users pay once to unlock content permanently.

Permanent Access

Unlocks are stored on-chain and never expire.

Grant Free Access

Creators can grant access to users without payment.

Creator Functions

createGate(contentId, price, token)
Create a new gated content entry

// Gate content at $10

createGate(contentId, 10000000, tokenAddress)

  • contentId: Unique bytes32 identifier for the content
  • price: Price in token units (6 decimals)
  • token: Payment token address (or address(0) for any supported token)
updateGatePrice(contentId, price)
Change the price of an existing gate

Updates the price for new unlocks. Existing unlocks are unaffected.

deactivateGate(contentId)
Disable a gate (prevents new unlocks)
reactivateGate(contentId)
Re-enable a previously deactivated gate
grantAccess(user, contentId)
Grant free access to a user

Creators can give users access without requiring payment. Useful for giveaways, early supporters, or promotional access.

User Functions

unlock(creator, contentId, token)
Pay to unlock gated content

Pays the gate price to the creator and records the unlock on-chain. Requires token approval first.

unlockByUsername(username, contentId, token)
Unlock using creator's username instead of address

Same as unlock, but resolves the creator address from their registered username.

View Functions

hasAccess(user, creator, contentId)
Check if a user has unlocked content

Returns true if the user has paid for or been granted access to the content.

getGate(creator, contentId)
Get gate configuration

Returns price, token, active status, and unlock count for a gate.

getUnlock(user, creator, contentId)
Get unlock details for a user

Returns when content was unlocked, amount paid, and token used.

Events

  • GateCreated(creator, contentId, price, token)
  • GateUpdated(creator, contentId, price, active)
  • ContentUnlocked(user, creator, contentId, amount, token)
  • AccessGranted(user, creator, contentId)

Content ID Generation

Content IDs are bytes32 values that uniquely identify your gated content. You can generate them from any string using keccak256 hashing.

// JavaScript example

import { keccak256, toBytes } from 'viem'

const contentId = keccak256(toBytes('my-exclusive-content'))

Integration

Use the Norn dashboard to create and manage gates, or integrate directly with the contract for custom implementations.