Recipe: Token-gated launch
A seller restricts an offer to holders of a specific ERC-20, ERC-721, or ERC-1155.
// Holders of >= 1 of NFT 0xabc... can buy, once each
await sdk.createOfferWithCondition({
offer: {
price: "1000000",
quantityAvailable: "100",
exchangeToken: USDC_ADDRESS,
metadataUri,
metadataHash,
// … dates, dispute resolver, agent …
},
condition: {
method: 1, // 1 = Threshold
tokenType: 1, // 0=ERC20, 1=ERC721, 2=ERC1155
tokenAddress: "0xabc…",
tokenId: "0", // unused for threshold-721 (any token in collection)
threshold: "1", // hold at least 1
maxCommits: "1", // each holder can buy once
gating: 0, // 0=PerAddress, 1=PerTokenId
},
})Variations
- Per-tokenId drops — use
gating: 1and eachtokenIdcan be usedmaxCommitstimes. - Open after threshold — set
thresholdto e.g.5to require holding 5+ NFTs. - ERC-20 thresholds — pass
tokenType: 0and threshold in token base units.
Caveats
- The Diamond reads the buyer's token balance at commit time. Flash-loaning the gating token won't work for ERC-721 (balance is checked atomically inside the tx), but the buyer could buy + commit + sell in one bundle. For very high-value drops, consider a snapshot.
- Condition enum naming has drifted in older SDK versions (
SpecificToken↔TokenRange). Pin SDK version.