# End-to-end Example

## 1. Get your API keys

Create a [3mint](https://app.3mint.io) account and find your API key on the Settings page.

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2FadQVhOQaamCVnsyoNsVI%2FScreen%20Shot%202022-11-23%20at%2010.52.09%20PM.png?alt=media&#x26;token=eaca68aa-c91a-420b-9b33-985124867d2f" alt=""><figcaption><p>The key displayed is for demonstration purposes only and will not work in production</p></figcaption></figure>

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.&#x20;

## 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).&#x20;

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"**

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2F90eDQEujjZ5LNJhaVW3q%2FScreen%20Shot%202022-11-27%20at%2011.25.38%20PM.png?alt=media&#x26;token=db77759b-f180-4bdf-9650-49417f8aee9c" alt=""><figcaption><p>ERC-1155 is the best choice if you want to create more than 1 of the same NFT</p></figcaption></figure>

**B. Input Collection Data**

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2F5e2MC8wVh82VxrTELNWf%2FScreen%20Shot%202022-11-28%20at%203.58.48%20PM.png?alt=media&#x26;token=b99d2d04-a77c-40ea-97d3-fc5a6a64635b" alt=""><figcaption><p>The image uploaded will be visible on platforms like OpenSea</p></figcaption></figure>

**C. Choose Decentralized blockchain as you Data Location**

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2Fat514UvrFJHiVjO5Kkzh%2FScreen%20Shot%202022-11-23%20at%2011.06.52%20PM.png?alt=media&#x26;token=4ed8bcc3-a2d3-4a4b-a1b5-4a2f99b158a3" alt=""><figcaption><p>If you want to change your NFTs after they have been minted, Designated Server would be the preferred option</p></figcaption></figure>

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.&#x20;

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2FIVRlDtmZMFCuMirBcaLG%2FScreen%20Shot%202022-11-28%20at%204.01.10%20PM.png?alt=media&#x26;token=68f9535b-77e5-48f4-a7b1-9293f07e4068" alt=""><figcaption><p>The contract address can be copied and searched on Etherscan</p></figcaption></figure>

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.

<figure><img src="https://1032756590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEIcCxTJJ3QAa0VWWBYx%2Fuploads%2FuGpvMtW7rdsaT9rCE73A%2FScreen%20Shot%202022-11-23%20at%2011.20.35%20PM.png?alt=media&#x26;token=9f5af112-cb41-45b3-830c-5647e8f236af" alt=""><figcaption><p>You can add as many attributes as you'd like</p></figcaption></figure>

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.&#x20;

## 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.

{% hint style="info" %}
Every API request must include Content-Type and X-API-KEY headers.
{% endhint %}

{% tabs %}
{% tab title="curl" %}
{% code lineNumbers="true" %}

```json
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
       }'
```

{% endcode %}
{% endtab %}

{% tab title="Axios (JS)" %}
{% code lineNumbers="true" %}

```javascript
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));
```

{% endcode %}
{% endtab %}

{% tab title="Fetch (JS)" %}
{% code lineNumbers="true" %}

```javascript
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));
```

{% endcode %}
{% endtab %}
{% endtabs %}
