token gating
Token gating is using ownership of a token or NFT as the key to a door — a Discord channel, a private website, an event, a piece of content, or a feature. Instead of issuing usernames and passwords, you say 'if your wallet holds this token, you're in'. The membership card is the token itself, which means access can be granted, revoked, and traded simply by tokens moving between wallets, with no central account database.
The check has two parts: proving you control a wallet, and proving that wallet holds the required token. Control is shown by signing a challenge message with the wallet's private key (the 'Sign-In with Ethereum' pattern), which costs no gas and moves nothing. Ownership is then read from chain state — typically balanceOf(wallet) greater than zero for an ERC-20 or NFT collection, or ownerOf for a specific token id, sometimes with a minimum balance or a specific trait. Off-chain, services like Collab.Land bridge this to Discord roles; on-chain, a contract can simply require the caller's balance before letting them act.
The subtlety is timing and revocability. Because holdings change, gating must decide when to check: once at entry, continuously, or at a snapshot block (common in DAO voting, to freeze who is eligible and prevent buying votes mid-vote). It also inherits token risks — flash-loan attacks can momentarily grant someone a huge balance to pass a balance check, and a sold NFT should drop the holder's access, which off-chain systems must actively re-verify rather than assume.
A balance check at a single instant is gameable — flash loans can inflate a balance for one transaction. Robust gating checks at a snapshot or over time, and pairs the balance read with a signature proving wallet control.