3mint
Search…
⌃K

Token Gate An Article

Programmatic gating for customers holding an Ethereum ERC1155 NFT
To token gate an article, your users first need to hold the right NFT. If you want to create this NFT and send it to them, please check our Airdrop an NFT example above!

1. Get your API keys

Create a 3mint account and find your API key on the Settings page.
The key displayed is for demonstration purposes only and will not work in production
Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.
The key received should remain secret, which means it should only be accessed on the back end. Authorization to the API is performed via the X-API-KEY header.

2. Check Ownership

To verify whether a user has the right NFT, send an authenticated request to the tokenGate endpoint from your website. If you would like to add over parameters (length of time held, quantity held, metadata attributes, please check our Token Gating guide)
Every API request must include Content-Type and X-API-KEY headers.
curl
Axios (JS)
Fetch (JS)
1
curl -X POST https://api.3mint.io/api/v1/tokenGate
2
-H "Content-Type: application/json"
3
-H "X-API-KEY: [YOUR_API_KEY]"
4
-d '{"walletAddress": "[WALLET_OF_USER]",
5
"chain": "ethereum",
6
"network": "mainnet",
7
"requirements": [
8
{
9
"type": "erc721",
10
"contractAddress": "[PROJECT_CONTRACT_ADDRESS]",
11
"minBalance": 1,
12
}
13
]
14
}'
1
import axios from 'axios';
2
​
3
// replace with your 3mint api key
4
const apiKey = 'demo';
5
const url = 'https://api.3mint.io/api/v1/tokenGate';
6
​
7
// Include conditions to verify
8
const ownerAddress = '[WALLET_OF_USER]'
9
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'
10
​
11
var requestOptions = {
12
method: 'POST',
13
url: `${url}`,
14
headers: {
15
'Content-Type': 'application/json',
16
'X-API-KEY': `${apiKey}`
17
},
18
data: {
19
'walletAddress': `${ownerAddress}`,
20
'chain': 'ethereum',
21
'network': 'mainnet',
22
'requirements': [
23
{
24
'type': 'erc721',
25
'contractAddress': `${contractAddress}`,
26
'minBalance': 1,
27
}
28
]
29
}
30
};
31
​
32
axios(config)
33
.then(response => console.log(response))
34
.catch(error => console.log(error));
1
import fetch from 'node-fetch';
2
​
3
// replace with your 3mint api key
4
const apiKey = 'demo';
5
const fetchURL = 'https://api.3mint.io/api/v1/tokenGate';
6
​
7
// Include conditions to verify
8
const ownerAddress = '[WALLET_OF_USER]'
9
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'
10
​
11
var requestBody = JSON.stringify({
12
'walletAddress': `${ownerAddress}`,
13
'chain': 'ethereum',
14
'network': 'mainnet',
15
'requirements': [
16
{
17
'type': 'erc721',
18
'contractAddress': `${contractAddress}`,
19
'minBalance': 1,
20
}
21
]
22
});
23
​
24
var requestOptions = {
25
method: 'POST',
26
headers: {
27
'Content-Type': 'application/json',
28
'X-API-KEY': `${apiKey}`
29
},
30
body: requestBody,
31
};
32
​
33
// Make the request and print the formatted response:
34
fetch(fetchURL, requestOptions)
35
.then(response => response.json())
36
.then(response => console.log(response))
37
.catch(error => console.log('error', error));

Response (by default)

1
{ "result" : true }