In our practice, we've encountered dozens of NFT-membership integrations and seen how erroneous contract architecture leads to privilege leaks. The most common mistake: developers implement a check like ownerOf(tokenId) == msg.sender and consider the problem solved. But NFTs can be lent, flash loaned (for one block), or listed on a marketplace while retaining access through delegation. A proper membership system requires understanding these vectors and explicitly choosing a trust model. Our experience — 5 years in DeFi and NFT, over 20 successful projects — guarantees a reliable solution.
Contract Architecture
Base Model: Token Ownership
For simple use cases (content access, Discord verification), ERC-721 with a balanceOf(user) > 0 check suffices. balanceOf is cheaper than ownerOf for multiple tokens and more robust against edge cases. However, it does not protect against listing: the owner can list the NFT on OpenSea, access gated content, and then cancel the listing.
Tiered Membership via ERC-1155
For multiple access levels (Bronze/Silver/Gold, or month/year/lifetime), ERC-1155 is natively better than ERC-721. Each tokenId represents a tier:
uint256 public constant TIER_BRONZE = 1;
uint256 public constant TIER_SILVER = 2;
uint256 public constant TIER_GOLD = 3;
function getMemberTier(address user) external view returns (uint256) {
if (balanceOf(user, TIER_GOLD) > 0) return TIER_GOLD;
if (balanceOf(user, TIER_SILVER) > 0) return TIER_SILVER;
if (balanceOf(user, TIER_BRONZE) > 0) return TIER_BRONZE;
return 0; // not a member
}
Tiers with cumulative access: Gold includes everything in Silver and Bronze. We check from top to bottom.
Why Use Soulbound Tokens for Membership?
Soulbound tokens (EIP-5192) eliminate the transferability problem: they are permanently tied to the owner's address. If the goal is to tie access to a specific person rather than a wallet, use EIP-5192 or simply override transfer functions:
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 batchSize
) internal override {
require(from == address(0) || to == address(0), "Soulbound: non-transferable");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
from == address(0) — mint, to == address(0) — burn. Everything else is forbidden. Problem: losing keys means losing membership. Solution: provide a recovery mechanism via multisig or social recovery (ERC-4337 account abstraction).
How to Implement Time-Based Subscriptions in ERC-721?
Expiring membership requires storing dates. Two approaches:
| Approach |
On-chain timestamp |
Signature-based off-chain |
| Storage |
Mapping tokenId → expiresAt |
Signed JWT with expiry (on backend) |
| Gas for check |
Storage write |
No writes, cheaper |
| Trust |
Full (all on-chain) |
Requires trust in signing service |
| Suitable for |
Fully on-chain systems |
Web2-hybrid and API integrations |
For fully on-chain, use the first approach. ERC-5643 is a draft standard for subscription NFTs with renewSubscription(uint256 tokenId, uint64 duration).
Comparison of Membership Models
| Feature |
ERC-721 |
ERC-1155 |
Soulbound (EIP-5192) |
| Tiers |
Single type |
Multiple tiers |
Single type (if one) |
| Transfer |
Yes |
Yes |
No |
| Gas for check |
balanceOf ~30k |
balanceOfBatch ~40k |
balanceOf ~30k |
| Complexity |
Low |
Medium |
Medium |
| Application |
Simple access |
Tiered membership |
Personal subscriptions |
Integration with Off-Chain Systems
Verification via EIP-1271
For membership verification on the backend without transactions: the user signs a message (EIP-191 or EIP-712), the backend verifies via eth_call to isValidSignature(bytes32 hash, bytes signature) for smart wallets or via ecrecover for EOAs. This is a standard off-chain membership check.
Delegation via delegate.cash
delegate.cash (de facto standard) allows NFT owners to delegate from a cold wallet to a hot wallet. For membership systems, this is important: holders store expensive NFTs in cold wallets and interact via hot wallets. Integration:
IDelegationRegistry constant DELEGATION_REGISTRY =
IDelegationRegistry(0x00000000000076A84feF008CDAbe6409d2FE638B);
function isMember(address user) public view returns (bool) {
if (balanceOf(user) > 0) return true;
// Check delegation
address[] memory delegators = DELEGATION_REGISTRY.getDelegationsByDelegate(user);
for (uint i = 0; i < delegators.length; i++) {
if (balanceOf(delegators[i]) > 0) return true;
}
return false;
}
This is a real need: Moonbirds, Doodles, and other major collections have integrated delegate.cash precisely for this.
Mint Mechanism and Pricing
Allowlist via Merkle Tree is the standard for presale. Gas savings reach 70% compared to storing the list on-chain:
bytes32 public merkleRoot;
function allowlistMint(bytes32[] calldata proof) external payable {
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(proof, merkleRoot, leaf), "Invalid proof");
require(msg.value >= PRICE, "Insufficient payment");
_safeMint(msg.sender, _nextTokenId());
}
The proof is generated off-chain (merkletreejs), the root is uploaded to the contract. A list of 10,000 addresses results in a proof of ~14 hashes, calldata ~450 bytes.
Example calculation of Merkle proof for 10,000 addresses
A tree of depth 14 has 16,384 leaves. For a proof of 14 hashes (32 bytes each), calldata is 14*32 + 4 (offset) ≈ 452 bytes. At a gas price of 100 gwei, the savings compared to storing the list on-chain is about 0.005 ETH.
What's Included in the Work
- Audit of current architecture and requirement specification
- Development of smart contracts (Solidity 0.8.x, OpenZeppelin)
- Writing unit tests (Foundry/Hardhat) with edge case coverage
- Integration with backend (EIP-1271, delegate.cash) and frontend (wagmi, RainbowKit)
- Contract documentation (NatSpec) and deployment instructions
- Deployment to mainnet/testnet, verification setup on Etherscan
- Post-launch support (optional)
Timeline Estimates
ERC-721 membership with tiers and Merkle allowlist — from 2 days. Adding time-based subscriptions (ERC-5643 style) plus backend verification — another 1-2 days. A full system with delegation, soulbound recovery, and frontend — 4-5 days. Contact us for a precise estimate of your project. Order the development of your membership system and get a consultation from our engineer.
Why does NFT marketplace development require a comprehensive approach?
We see that at first glance, an NFT contract looks simple: ERC-721, mint(), IPFS for metadata — that's it. In practice, it's this 'simplicity' that hides most problems — from bots buying out the entire mint in the first block to broken royalties on the secondary market. We often hear: Make a collection like others in a week — and a month later it turns out gas has tripled due to an unoptimized for loop, or OpenSea cannot see metadata after reveal. We know each of these pitfalls and build processes to avoid them.
Over 5 years of working with blockchains, we have implemented 40+ NFT projects, including marketplaces with dynamic attributes and cross-chain bridges. We have accumulated a library of proven templates — some of which we break down below.
Which standard to choose: ERC-721 or ERC-1155?
ERC-721 — each token is unique, one owner. Suitable for collections where each NFT has individual attributes and a direct owner → tokenId mapping.
ERC-1155 — multi-token standard: one contract holds both fungible and non-fungible tokens. It uses balanceOf(address, tokenId) instead of ownerOf(tokenId). A single transaction can transfer multiple different tokens via safeBatchTransferFrom. This saves gas on bulk operations — important for game items, tickets, edition collections. ERC-1155 is 2–3× more gas-efficient than ERC-721 for batch transfers.
| Criteria |
ERC-721 |
ERC-1155 |
| Token uniqueness |
Each token is unique |
One tokenId can have multiple copies |
| User balance |
Only ownerOf (one) |
balanceOf(address, tokenId) |
| Gas per transfer |
~25,000 gas |
~18,000 gas (batch even lower) |
| Batch operations |
No native support |
safeBatchTransferFrom |
| Ideal scenario |
Art collections, PFPs |
Games, tickets, editions |
Specific case: a game project with 50 types of items, each with a supply of 10,000. ERC-721 — 500,000 unique tokens, huge overhead on mappings. ERC-1155 — 50 tokenIds, balanceOf per player. Gas per transfer is 2–3 times lower, contract deployment is cheaper. For such tasks, we use OpenZeppelin ERC-1155 with custom modifications.
Metadata: on-chain vs IPFS vs centralized
The standard route is tokenURI() returning a link to a JSON with fields name, description, image, attributes. Three storage options:
- Centralized server — cheapest and most flexible. Risk: server goes down, company closes — NFT loses metadata. Not suitable for collections claiming long-term value.
- IPFS + Pinning — content-addressed storage, the link is bound to the content hash. Pinata or NFT.Storage provide pinning. Important: IPFS does not guarantee availability by itself — an active pinning service is needed. If it shuts down, data may disappear if no one keeps a copy.
- On-chain metadata — base64-encoded SVG or JSON directly in tokenURI. Maximum reliability, but expensive: for a collection of 10,000 tokens, gas costs may exceed $5,000. Suitable for generative art projects where visuals are generated from on-chain attributes (Nouns, Loot).
For most collections, we choose IPFS with Pinata for images + on-chain attributes for traits — a good balance. We validate files against a JSON Schema before upload; a typical mistake is unescaped quotes, causing marketplaces to display a blank screen.
Typical JSON metadata format
{
"name": "Token #1",
"description": "A unique NFT",
"image": "ipfs://QmHash/image.png",
"attributes": [{"trait_type": "Background", "value": "Red"}]
}
Dynamic NFT: metadata that changes
Dynamic NFT updates metadata in response to external events — match results, character levels, real-world data via Chainlink. Architecturally, it's a combination: the smart contract stores state → tokenURI() generates metadata from the state on-chain. Caching problem: OpenSea and other marketplaces aggressively cache. The standard invalidation mechanism is a MetadataUpdate(tokenId) event from ERC-4906. OpenSea listens to this event and clears the cache. Without it, updated metadata may not appear for weeks.
Chainlink Automation (formerly Keepers) for automatically updating state on the contract on a schedule or condition — a standard solution for dynamics.
How to protect mint from bots?
Allowlist via Merkle tree — standard. The list of addresses is hashed into a Merkle root, stored in the contract. During mint, the user provides a Merkle proof — the contract verifies without storing the full list. We use OpenZeppelin MerkleProof library.
Reveal mechanism — on mint, a placeholder is issued; real traits are revealed after the sale ends. Otherwise, bots can scan pending transactions and snipe rare traits via frontrunning. But reveal requires a commitment scheme — the random seed must be fixed before mint or use Chainlink VRF.
Chainlink VRF for fair randomization of traits. VRF request at mint → callback with verifiable random number → assign traits. This adds ~2 transactions and latency but guarantees fairness. Chainlink VRF v2.5.
Rate limiting — require(mintedPerWallet[msg.sender] < maxPerWallet). Does not protect against multi-wallets but raises attack cost. For premium projects, we often add proof-of-work directly in the contract (via EIP-2612 signatures).
Royalties: the real market state
ERC-2981 — on-chain royalty standard. The contract returns (recipient, amount) for any sale price via royaltyInfo(tokenId, salePrice). Marketplaces query this on each sale. Problem: adherence to royalties is voluntary for marketplaces. Blur launched with zero royalties, triggering a wave of other platforms. The situation has partially stabilized: OpenSea supports ERC-2981, Blur added optional ones. Royalty payments can represent 5–10% of secondary sale volume, so getting them right matters.
Attempts to enforce royalties on-chain by restricting transfers only to approved marketplaces (operator filtering) were proposed by OpenSea via OperatorFilterRegistry. This breaks composability — you cannot transfer an NFT through a custom contract. Most serious projects have abandoned this approach. For projects where royalties are critical, we build a custom marketplace within the ecosystem plus an incentive structure for users to trade there.
Lazy minting and gas-free mint
Gas-free mint via signature: the creator signs a voucher (tokenId, tokenURI, price, signature), the buyer provides the voucher in mint() — the contract verifies the signature via ECDSA.recover() and mints. Works on OpenSea via their Seaport protocol. Seaport is an optimized contract with minimal gas usage. Understanding its mechanics is important when integrating custom marketplace logic.
Stack for NFT projects
- Contracts: Solidity 0.8.x, OpenZeppelin ERC721Enumerable or ERC721A (Azuki) for gas-optimized batch mint, ERC1155 from OpenZeppelin
- VRF and automation: Chainlink VRF v2.5, Chainlink Automation
- Storage: Pinata (IPFS pinning), NFT.Storage, Arweave for permanent storage
- Marketplace: OpenSea Seaport protocol, custom integration
- Frontend: wagmi v2 + viem, RainbowKit for wallet connection, React + TypeScript
Development process
-
Mint mechanics design — allowlist, public sale, price curve (Dutch auction or fixed), limits per wallet
-
Contracts — with Foundry fuzz tests on mint limits, Merkle proof verification, royalty calculations
-
IPFS deployment — upload metadata and images before reveal, pin on at least two services
-
Reveal — if using Chainlink VRF, test on testnet mandatory: VRF subscription must be funded with LINK tokens
-
Marketplace integration — verify collection on OpenSea, configure royalties, test MetadataUpdate events
-
Deployment and monitoring — Tenderly for reentrancy detection, Etherscan API for contract verification, set up event alerts
Deliverables
- Source code of smart contracts (Solidity, Rust for Solana) with comments
- Test suite (Foundry/Hardhat) with ≥90% coverage
- Deployment documentation and integration instructions
- Access to pinning services (Pinata/Pinfluence)
- Metadata generation scripts (Python/JS)
- Support during marketplace verification
- 30 days of technical support after deployment
Timeline
| Task type |
Approximate timeline |
| Basic ERC-721 without reveal |
from 2 weeks |
| NFT collection with allowlist, reveal, VRF |
from 5 weeks |
| ERC-1155 with marketplace and royalties |
from 6 weeks |
| Dynamic NFT with external data |
from 8 weeks |
Cost is calculated individually after auditing your task. Send a brief with your project description — we will provide a transparent estimate within 3 business days. For regular clients, there is a flexible discount system on batch orders. If you need a gas-optimized contract, order a free gas analysis. Get a consultation on marketplace architecture — leave a request, and we will evaluate your project in three days.