Code Snippets
Different ways to token gate
NFT Ownership
User owns 2 ERC721 NFTs
This example verifies that an address holds exactly 2 NFTs from the Bored Ape Yacht Club collection.
curl -X POST https://api.3mint.io/api/v1/tokenGate
-H "Content-Type: application/json"
-H "X-API-KEY: [YOUR_API_KEY]"
-d '{"walletAddress": "0x958fb436dB50DB2F689C364712113cc226b38151",
"chain": "ethereum",
"network": "mainnet",
"requirements": [
{
"type": "erc721",
"contractAddress": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
"minBalance": 2,
"maxBalance": 2
}
]
}'import axios from 'axios';
// replace with your 3mint api key
const apiKey = 'demo';
const url = 'https://api.3mint.io/api/v1/tokenGate';
var requestOptions = {
method: 'POST',
url: `${url}`,
headers: {
'Content-Type': 'application/json',
'X-API-KEY': `${apiKey}`
},
data: {
'walletAddress': '0x958fb436dB50DB2F689C364712113cc226b38151',
'chain': 'ethereum',
'network': 'mainnet',
'requirements': [
{
'type': 'erc721',
'contractAddress': '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D',
'minBalance': 2,
'maxBalance': 2
},
]
}
};
axios(config)
.then(response => console.log(response))
.catch(error => console.log(error));User owns at least 1 ERC1155 with a specific token ID
This example verifies that an address holds at least one NFT from the Crypto Baristas collection.
User owns multiple ERC721 NFTs from different collections
This example verifies that an address holds at least 1 Bored Ape and two ApeDocs NFT.
User owns 1 ERC721 NFT for at least 6 months and 10 days
You cannot have both minTime and minBalance parameters set in the same object request.
This example verifies that an address has held 1 NFT from the Bored Ape Yacht Club collection for at least 6 months and 10 days.
User owns 1 ERC721 NFT since the beginning of 2022
minTimestamp must follow format in example below (e.g., 2014-09-08T08:02:17.160Z)
This example verifies that an address has held 1 NFT from the Bored Ape Yacht Club collection since the beginning of 2022.
User owns 1 ERC721 NFT with specific metadata attributes
This example verifies that an address holds at least 1 Crypto Punk with two attribute types.
Token Ownership
Address owns at least 2 WETH
Address has held at least 2 WETH for 30 days
Coin Ownership
Address owns at least 2.5 ETH
Combos
User owns 5 ETH or 2 WETH plus 1 to 4 ERC721 NFTs
This example verifies that an address holds at least 5 ETH or 2 WETH and 1 to 4 ApeDocs NFTs.
Last updated