3mint
Search
⌃K
Comment on page

End-to-end Example

Programmatically minting an Ethereum ERC1155 NFT

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. Deploy a contract

The building block of any NFT is the contract that you first need to deploy to a blockchain. Think of this contract as public way to show who owns which NFT (i.e., it's a simple table that has the user’s wallet address in the left column and the NFT the user owns in the right column).
To deploy a contract, go to the Contracts page and click the "Create contract" button. From there, you need to choose the type of contract you want to deploy (A), input details regarding the contract you are deploying (B), and since we are launching an NFT, we'll also choose where our NFT data should be stored (C).
A. Choose "One or More Copies"
ERC-1155 is the best choice if you want to create more than 1 of the same NFT
B. Input Collection Data
The image uploaded will be visible on platforms like OpenSea
C. Choose Decentralized blockchain as you Data Location
If you want to change your NFTs after they have been minted, Designated Server would be the preferred option
Once everything you've chosen looks good, press "Deploy" at the bottom of the screen and the contract will be deployed to your blockchain and network of choice. No wallet, crypto, or private key needed! After a few seconds, you'll be directed back to the main page and you should see your contract included in the table.

3. Upload NFT Data

Now it's time to upload the digital content and metadata your NFTs will use when minted (i.e., created and sent to someone's wallet). To do this, click on the "info" button on the right-hand side of the contract row.
The contract address can be copied and searched on Etherscan
From there, you'll be taken to a page that shows you all the NFT data you have prepared (none so far, but we'll change that in a second!). Click on "Single Upload" and fill in your NFT details.
You can add as many attributes as you'd like
Once uploaded, this data will live on a decentralized blockchain forever, ensuring your holders truly own this data. If you want to upload more than 1 NFT at a time, just use the "Batch Upload" button instead.
Just like that, you now have a contract deployed and the NFT data needed to start sending your NFTs programmatically.

4. Mint with Code

Minting can be done directly through your codebase. If you have a POS system, you can deliver these NFTs for certain purchases that your customers make.
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/mint
2
-H "Content-Type: application/json"
3
-H "X-API-KEY: [YOUR_API_KEY]"
4
-d '{"to": ["[WALLET_OF_USER]"],
5
"chain": "ethereum",
6
"network": "mainnet",
7
"type":"erc1155",
8
"contractAddress": "[CONTRACT_ADDRESS]",
9
"quantity": 1
10
}'
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/mint';
6
​
7
// Include conditions to verify
8
const to = '[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
'to': [`${to}`],
20
'chain': 'ethereum',
21
'network': 'mainnet',
22
'type':'erc1155',
23
'contractAddress': `${contractAddress}`,
24
'quantity': 1
25
}
26
};
27
​
28
axios(config)
29
.then(response => console.log(response))
30
.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/mint';
6
​
7
// Include conditions to verify
8
const to = '[WALLET_OF_USER]'
9
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'
10
​
11
var requestBody = JSON.stringify({
12
'to': `${to}`,
13
'chain': 'ethereum',
14
'network': 'mainnet',
15
'type':'erc1155',
16
'contractAddress': `${contractAddress}`,
17
'quantity': 1
18
});
19
​
20
var requestOptions = {
21
method: 'POST',
22
headers: {
23
'Content-Type': 'application/json',
24
'X-API-KEY': `${apiKey}`
25
},
26
body: requestBody,
27
};
28
​
29
// Make the request and print the formatted response:
30
fetch(fetchURL, requestOptions)
31
.then(response => response.json())
32
.then(response => console.log(response))
33
.catch(error => console.log('error', error));
Last modified 10mo ago