3mint
  • 👋Welcome to 3mint
  • 💻3mint Platform
    • Introduction
    • Deploy a contract
    • Upload your NFT data
    • Create checkout links
    • Add customers
    • Monitor your links
  • ⌨️Developer Guides
    • Introduction
    • Contracts
      • Contract Architecture
      • End-to-end Example
    • Mint
      • How To
      • End-to-end Example
      • Code Snippets
    • Wallets
      • End-to-end Example
      • Mobile Pass
        • Creating Passes
    • Token Gating
      • End-to-end Example
      • Code Snippets
  • 📖API Reference
    • Overview
    • Contracts
      • Deploy Contract
      • Get Contract
    • Collectibles
      • Get All Templates
      • Mint Collectible
    • Wallets
      • Create Wallet
      • Get Wallet
    • Customers
      • Create Customer
      • Get Customer
      • Delete Customer
    • Claim Links
      • Create Link
      • Update Link
    • Token Gating
      • Create Gate
  • ❓FAQ
    • Web3 101
    • Platform
Powered by GitBook
On this page
  • 1. Get your API keys
  • 2. Deploy a contract
  • 3. Upload NFT Data
  • 4. Mint with Code
  1. Developer Guides
  2. Mint

End-to-end Example

Programmatically minting an Ethereum ERC1155 NFT

PreviousHow ToNextCode Snippets

Last updated 2 years ago

1. Get your API keys

Create a account and find your API key on the Settings page.

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"

B. Input Collection Data

C. Choose Decentralized blockchain as you Data Location

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.

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.

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 -X POST https://api.3mint.io/api/v1/mint   
   -H "Content-Type: application/json"
   -H "X-API-KEY: [YOUR_API_KEY]"
   -d '{"to": ["[WALLET_OF_USER]"],
       "chain": "ethereum",
       "network": "mainnet",
       "type":"erc1155",
       "contractAddress": "[CONTRACT_ADDRESS]",
       "quantity": 1
       }'
import axios from 'axios';

// replace with your 3mint api key
const apiKey = 'demo';
const url = 'https://api.3mint.io/api/v1/mint';

// Include conditions to verify
const to = '[WALLET_OF_USER]'
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'

var requestOptions = {
  method: 'POST',
  url: `${url}`,
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': `${apiKey}`
  },
  data: {
    'to': [`${to}`],
    'chain': 'ethereum',
    'network': 'mainnet',
    'type':'erc1155',
    'contractAddress': `${contractAddress}`,
    'quantity': 1
   }
};

axios(config)
.then(response => console.log(response))
.catch(error => console.log(error));
import fetch from 'node-fetch';

// replace with your 3mint api key
const apiKey = 'demo';
const fetchURL = 'https://api.3mint.io/api/v1/mint';

// Include conditions to verify
const to = '[WALLET_OF_USER]'
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'

var requestBody = JSON.stringify({
  'to': `${to}`,
    'chain': 'ethereum',
    'network': 'mainnet',
    'type':'erc1155',
    'contractAddress': `${contractAddress}`,
    'quantity': 1
});

var requestOptions = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': `${apiKey}`
  },
  body: requestBody,
};

// Make the request and print the formatted response:
fetch(fetchURL, requestOptions)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(error => console.log('error', error));
⌨️
3mint
The key displayed is for demonstration purposes only and will not work in production
ERC-1155 is the best choice if you want to create more than 1 of the same NFT
The image uploaded will be visible on platforms like OpenSea
If you want to change your NFTs after they have been minted, Designated Server would be the preferred option
The contract address can be copied and searched on Etherscan
You can add as many attributes as you'd like