(Note · · 5 min read)

Gating a feature on what someone holds

A discount for holders, a feature for stakers, access for people with a particular token. The rule is simple and the implementation has a specific weakness: the thing being checked can change the instant after you check it, and the check usually happens in the one place that cannot be trusted.

By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka

Connecting a wallet is not signing in

A browser reporting an address proves nothing — anyone can claim any address. Eligibility must be established for an address whose control has been demonstrated, which means a signature over a message naming your application, with a nonce and an expiry.

Verify that signature on the server and derive the address from it rather than accepting one alongside it. An address passed as a parameter is a request to be treated as somebody else.

Check on the server, against the chain

Read the holding yourself from a node you trust. A balance reported by the client, or read in the browser and submitted, is a number the user can choose — and the discount is exactly the incentive to do so.

The browser's check is for showing and hiding things. The server's check is what decides. Same rule as any permission: a hidden feature is never the guard.

Eligibility expires

Tokens move. Someone eligible at ten o'clock can have sold by ten past, and a system that checks once and remembers grants benefits indefinitely on the basis of holdings that no longer exist.

Re-check at the moment of the action that depends on it, not only at sign-in. Where a check is cached for cost reasons, keep the window short, record when it was made, and never let a cached result authorise something irreversible.

Decide what the rule actually is

Holding now, holding continuously, holding at a snapshot, or having staked and locked are four different rules with different gaming characteristics. A balance check at the moment of purchase can be satisfied by borrowing tokens for one transaction.

Where that matters, a rule based on locked or staked positions is much harder to game than one based on a spot balance — which is why staking with a lock period exists in the designs that take this seriously. Decide deliberately, write it down, and state it to users in those terms.

Say why, and what to do about it

Show the rule, the holding you read, the threshold and the time of the check. Someone who believes they qualify and is refused with no explanation files a support request; someone shown the figures either understands or has a specific discrepancy to report.

Handle the read failing as its own state. A node that is unavailable is not a user who is ineligible, and conflating them means an outage silently denies legitimate users.

Log the decision with its inputs

Record the address, the holding read, the block it was read at, the rule applied and the outcome. That makes a disputed benefit answerable, and a pattern of near-threshold attempts visible.

Where holdings drive a real-money benefit — a discount applied at checkout, merchandise priced by what is in a wallet — that record is also what reconciles the benefits granted against the revenue, which somebody will eventually ask you to produce.

Common questions

Is connecting a wallet enough to prove eligibility?

No. A browser reporting an address proves nothing. Require a signature over a message naming your application, with a nonce and expiry, verify it on the server, and derive the address from the signature rather than accepting one sent alongside it.

Where should a token holding be checked?

On the server, read from a node you trust. A balance reported by the client, or read in the browser and submitted, is a number the user can choose — and the benefit is exactly the incentive to do so. The browser's check only shows and hides.

How often should eligibility be re-checked?

At the moment of each action that depends on it, since tokens move and a one-time check grants benefits on holdings that no longer exist. Cache only briefly, record when the check was made, and never let a cached result authorise something irreversible.

What eligibility rule is hardest to game?

One based on staked or locked positions rather than a spot balance, because a balance check at the moment of purchase can be satisfied by borrowing tokens for a single transaction. Decide the rule deliberately and state it to users in those terms.

Need something like this built?