Tangocrypto
Search…
⌃K

Tutorial

Step 1: Create an NFT collection

Create collection request
HTTP
cURL
NodeJs
POST /<app-id>/v1/nft/collections HTTP/1.1
Host: cardano-testnet.tangocrypto.com
x-api-key: <your-api-key>
Content-Type: application/json
{
"name": "Tangocrypto Collection",
"description": "Tangocrypto collection description",
"url": "https://www.tangocrypto.com",
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
"policy": {
"lock": true,
"lock_time": "2022-02-24"
},
"metadata": {
"name": "<name>",
"asset_name": "<asset_name>",
"media_type": "<mime_type>",
"description": "<description>",
"files": [
{
"name": "<asset_name>",
"media_type": "<mime_type>",
"src": "<file_link>"
}
],
"attributes": {
"color": "<color>",
"body": "<body>",
"eyes": "<eyes>",
"face": "<face>",
"accessory": "<accessory>",
"collection": "Tangocrypto Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"website": "https://www.tangocrypto.com",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
}
}
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections' \
--header 'x-api-key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Tango Collection",
"description": "Tango collection description",
"url": "https://www.tangocrypto.com",
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
"policy": {
"lock": true,
"lock_time": "2022-02-24"
},
"metadata": {
"asset_name": "<asset_name>",
"name": "<name>",
"media_type": "<mime_type>",
"description": "<description>",
"files": [
{
"name": "<asset_name>",
"media_type": "<mime_type>",
"src": "<file_link>"
}
],
"attributes": {
"color": "<color>",
"body": "<body>",
"eyes": "<eyes>",
"face": "<face>",
"accessory": "<accessory>",
"collection": "Tangocrypto Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
}
}'
var axios = require('axios');
var data = JSON.stringify({
"name": "Tango Collection",
"description": "Tango collection description",
"url": "https://www.tangocrypto.com",
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
"policy": {
"lock": true,
"lock_time": "2022-02-24"
},
"metadata": {
"name": "<name>",
"asset_name": "<asset_name>",
"media_type": "<mime_type>",
"description": "<description>",
"files": [
{
"name": "<asset_name>",
"media_type": "<mime_type>",
"src": "<file_link>"
}
],
"attributes": {
"color": "<color>",
"body": "<body>",
"eyes": "<eyes>",
"face": "<face>",
"accessory": "<accessory>",
"collection": "Tangocrypto Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
}
});
var config = {
method: 'post',
url: 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections',
headers: {
'x-api-key': '<your-api-key>',
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
This endpoint returns the policy_id. You should post the policy id in your website, social media or any communication channel, you use for buyers to verify the authenticity of the tokens they buy.
{
"id": "e1d7fe1d97c64518a5c51011edcc1a31",
"name": "Tango Collection",
"url": "https://www.tangocrypto.com",
"description": "Tango collection description",
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
"token_count": 0,
"token_for_sale_count": 0,
"token_sold_count": 0,
"revenue": 0,
"income": 0,
"service_fee": 0,
"nft_fee": 0,
"tx_fee": 0,
"total_fees": 0,
"policy": {
"lock": true,
"lock_time": "2022-02-24T00:00:00.000Z",
"policy_id": "6a16d7d312dfcbcb4f676fa31893cf6c456508d84472309f3aa7c998",
"script": {
"type": "all",
"scripts": [
{
"type": "sig",
"keyHash": "76bcc8cf947649636f027e705a30ec66fa0476971aef51d219323c07"
},
{
"type": "before",
"slot": 54094491
}
]
}
},
"metadata": {
"label": "721",
"asset_name": "<asset_name>",
"name": "<name>",
"media_type": "<mime_type>",
"description": "<description>",
"files": [
{
"name": "<asset_name>",
"media_type": "<mime_type>",
"src": "<file_link_1>"
}
],
"attributes": {
"color": "<color>",
"body": "<body>",
"eyes": "<eyes>",
"face": "<face>",
"accessory": "<accessory>",
"collection": "Tangocrypto Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"website": "https://www.tangocrypto.com",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
},
"created_at": "2022-02-23T08:21:38.908Z",
"updated_at": "2022-02-23T08:21:38.908Z"
}

Step 2: Upload the images and set the metadata attributes

The next step is to upload the images and define the metadata for each NFT in the collection. Use the following API endpoint with the collection-id returned in step 1 as part of the path.
HTTP
cURL
NodeJs
POST /<app-id>/v1/nft/collections/<collection-id>/tokens HTTP/1.1
Host: cardano-testnet.tangocrypto.com
x-api-key: <your-api-key>
Content-Type: application/json
{
"tokens": [{
"name": "Tango 01",
"asset_name": "Tango01",
"description": "If you get all tangled up, just tango on.",
"media_type": "image/png",
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
"metadata_attributes": [{
"tag": "<color>",
"value": "Blue"
},
{
"tag": "<body>",
"value": "Skinny"
},
{
"tag": "<eyes>",
"value": "Blue"
},
{
"tag": "<face>",
"value": "rounded"
},
{
"tag": "<accessory>",
"value": "keyboard"
}
],
"custom_attributes": {
"serial_no": "12345545",
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
}
}]
}
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/tokens' \
--header 'x-api-key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"tokens": [{
"name": "Tango 01",
"asset_name": "Tango01",
"description": "If you get all tangled up, just tango on.",
"media_type": "image/png",
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
"metadata_attributes": [{
"tag": "<color>",
"value": "Blue"
},
{
"tag": "<body>",
"value": "Skinny"
},
{
"tag": "<eyes>",
"value": "Blue"
},
{
"tag": "<face>",
"value": "rounded"
},
{
"tag": "<accessory>",
"value": "keyboard"
}
],
"custom_attributes": {
"serial_no": "12345545",
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
}
}]
}'
var axios = require('axios');
var data = JSON.stringify({
"tokens": [{
"name": "Tango 01",
"asset_name": "Tango01",
"description": "If you get all tangled up, just tango on.",
"media_type": "image/png",
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
"metadata_attributes": [{
"tag": "<color>",
"value": "Blue"
},
{
"tag": "<body>",
"value": "Skinny"
},
{
"tag": "<eyes>",
"value": "Blue"
},
{
"tag": "<face>",
"value": "rounded"
},
{
"tag": "<accessory>",
"value": "keyboard"
}
],
"custom_attributes": {
"serial_no": "12345545",
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
}
}]
});
var config = {
method: 'post',
url: 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/tokens',
headers: {
'x-api-key': '<your-api-key>',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Response
{
"data": [
{
"id": "e9e00b33e0a34edcaf4534a2f96a637d",
"asset_name": "Tango01",
"name": "Tango 01",
"fingerprint": "asset1hzh0uut85ypcueu88422pmgf6twzj2c52f73a5",
"status": "FOR_SALE",
"description": "If you get all tangled up, just tango on.",
"image": "ipfs://QmP8uBgxmTpduCUbasQRCEpiq1g9KEjxuRfR5VcvifWoNo",
"media_type": "image/png",
"metadata_attributes": [
{
"name": "Attribute color",
"value": "Blue",
"tag": "<color>"
},
{
"name": "Attribute body",
"value": "Skinny",
"tag": "<body>"
},
{
"name": "Attribute eyes",
"value": "Green",
"tag": "<eyes>"
},
{
"name": "Attribute face",
"value": "Rounded",
"tag": "<face>"
},
{
"name": "Attribute accessory",
"value": "Keyboard",
"tag": "<accessory>"
}
],
"custom_attributes": {
"serial_no": "12345545",
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
},
"policy": {
"lock": true,
"lock_time": "2022-01-03T15:35:10.000Z",
"policy_id": "1373bf16cdea380e6c9c716d0f56f021b9e9ddea90b248dae6310d95",
"script": {
"type": "all",
"scripts": [
{
"type": "sig",
"keyHash": "ac1746df0ba039de81274d472a477fced610f57cebc5c7841074f54c"
},
{
"type": "before",
"slot": "46854826"
}
]
}
},
"metadata": {
"721": {
"1373bf16cdea380e6c9c716d0f56f021b9e9ddea90b248dae6310d95": {
"Tango01": {
"name": "Tango 01",
"description": "If you get all tangled up, just tango on.",
"image": "ipfs://QmP8uBgxmTpduCUbasQRCEpiq1g9KEjxuRfR5VcvifWoNo",
"mediaType": "image/png",
"color": "Blue",
"body": "Skinny",
"eyes": "Green",
"face": "Rounded",
"accessory": "Keyboard",
"collection": "Tangocrypto Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"website": "https://www.tangocrypto.com",
"copyright": "Tangocrypto 2022",
"serial_no": "12345545",
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
}
},
"version": "1.0"
}
},
"created_at": "2021-11-30T23:17:36.791Z",
"updated_at": "2021-11-30T23:17:36.791Z"
}
],
"status_code": 201
}

Step 3: Create sale phases

Now you have the collection created and uploaded the files and metadata, it's time to define how you are going to sell the NFTs.
Here we are going to create a sale phase for a pre-sale where we want to sell 1000 random NFTs. We have 4 price tiers and the buyers can select the tier they want to buy. For example, if a buyer want's to get 4 random NFTs they can select the Gold tier and pay 30 Ada.
Generate the sale phase with the price tiers and the links for the four buy buttons.
HTTP
cURL
POST /<app-id>/v1/nft/collections/<collection-id>/phases HTTP/1.1
Host: cardano-testnet-staging.tangocrypto.com
x-api-key: <your-api-key>
Content-Type: application/json
Content-Length: 662
{
"name": "pre-sale",
"type": "random",
"total_tokens": 1000,
"reservation_time": 300,
"price_tiers": [
{
"name": "Bronze",
"quantity": 1,
"supply": 1,
"price": 10000000
},
{
"name": "Silver",
"quantity": 2,
"supply": 1,
"price": 20000000
},
{
"name": "Gold",
"quantity": 4,
"supply": 1,
"price": 30000000
},
{
"name": "Platinum",
"quantity": 8,
"supply": 1,
"price": 60000000
}
]
}
curl --location --request POST 'https://cardano-mainnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/phases' \
--header 'x-api-key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "pre-sale",
"type": "random",
"total_tokens": 1000,
"reservation_time": 300,
"price_tiers": [
{
"name": "Bronze",
"quantity": 1,
"supply": 1,
"price": 10000000
},
{
"name": "Silver",
"quantity": 2,
"supply": 1,
"price": 20000000
},
{
"name": "Gold",
"quantity": 4,
"supply": 1,
"price": 30000000
},
{
"name": "Platinum",
"quantity": 8,
"supply": 1,
"price": 60000000
}
]
}'
Response
In the response we can see that each price tier has an associated payment link. Then we copy that link and embeded it in the button. When the buyer clicks on the button a new window with Tangopay will open and once the payment is done the NFTs are sent to the wallet.
{
"id": "81d190a7ed1847cc97cf515aa2a70bc2",
"type": "random",
"name": "pre-sale",
"active": true,
"reservation_time": 300,
"total_tokens": 1000,
"remaining_tokens": 1000,
"price_tiers": [
{
"id": 0,
"name": "Bronze",
"price": 10000000,
"quantity": 1,
"supply": 1,
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MTAwMDAwMDAsInByaWNlX2lkIjowLCJxdWFudGl0eSI6MSwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
},
{
"id": 1,
"name": "Silver",
"price": 20000000,
"quantity": 2,
"supply": 1,
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MjAwMDAwMDAsInByaWNlX2lkIjoxLCJxdWFudGl0eSI6Miwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
},
{
"id": 2,
"name": "Gold",
"price": 30000000,
"quantity": 4,
"supply": 1,
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MzAwMDAwMDAsInByaWNlX2lkIjoyLCJxdWFudGl0eSI6NCwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
},
{
"id": 3,
"name": "Platinum",
"price": 60000000,
"quantity": 8,
"supply": 1,
"payment_link": "https://by.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6NjAwMDAwMDAsInByaWNlX2lkIjozLCJxdWFudGl0eSI6OCwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
}
],
"created_at": "2022-05-24T03:10:58.988Z",
"updated_at": "2022-05-24T03:10:58.988Z"
}

Step 4: Sell the collection on your website

Create a button for every payment link and sell the collection on your website.
NFT Drop website
When the buyer clicks on the buy button a new window with Tangopay will be openend and from there the buyer can pay with any of the most used wallets in Cardano.

Example code in Nodejs

With this code you can create the collection, upload the tokens and generate the payment links.
const axios = require('axios').default;
const HOST = 'cardano-testnet.tangocrypto.com';
const APP_ID = '34492bb302cf4678a3a0ec93029c5bh67';
const API_KEY = '8888c8026e7i47b4b2527151e126e914';
axios.defaults.baseURL = `https://${HOST}/${APP_ID}/v1`;
axios.defaults.headers.common['x-api-key'] = API_KEY;
axios.defaults.headers.post['Content-Type'] = 'application/json';
const collection = {
"name": "Tango Collection",
"description": "Tango collection description",
"url": "https://www.tangocrypto.com",
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
"policy": {
"lock": true,
"lock_time": "2023-02-24"
},
"metadata": {
"asset_name": "<asset_name>",
"name": "<name>",
"image": "<image_link>",
"media_type": "<mime_type>",
"description": "<description>",
"attributes": {
"color": "<color>",
"right_eye": "<right_eye>",
"left_eye": "<left_eye>",
"mouth": "<mouth>",
"collection": "Faces Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
}
};
const tokensArr = {
"tokens": [
{
"asset_name": "FACE#01",
"name": "FACE#01",
"description": "Faces collection",
"media_type": "png",
"custom_attributes": {
"md5checksum": "b58e62a83802b2bf0792a4e983dd2ff3cf9e0c1e"
},
"metadata_attributes": [
{
"tag": "<color>",
"name": "Attribute color",
"value": "Light Blue"
},
{
"tag": "<left_eye>",
"name": "Attribute left eye",
"value": "Open"
},
{
"tag": "<right_eye>",
"name": "Attribute right eye",
"value": "Half"
},
{
"tag": "<mouth>",
"name": "Attribute mouth",
"value": "Astonishmed"
}
],
"image": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAABCRB0AEiAAECDoAJEDQ...A0ACBB0AEiDoAJAAQQeABPQu/W2h2FEAAMuy8PeE90ZE/PmXzxU5FgCgCT0R8f8BA0CEYwSaYAIAAAAASUVORK5CYII="
},
{
"asset_name": "FACE#02",
"name": "FACE#02",
"description": "Faces collection",
"media_type": "png",
"custom_attributes": {
"md5checksum": "bee6ddb26d7d9b5f7dccba997ec575d272d6981f"
},
"metadata_attributes": [
{
"tag": "<color>",
"name": "Attribute color",
"value": "Light Purple"
},
{
"tag": "<left_eye>",
"name": "Attribute left eye",
"value": "Closed"
},
{
"tag": "<right_eye>",
"name": "Attribute right eye",
"value": "Half"
},
{
"tag": "<mouth>",
"name": "Attribute mouth",
"value": "Happy"
}
],
"image": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KA.....IQdABIQNABIAFBB4AEBB0AEhB0AEhA0AEgAUEHgAR2tP/0YX/PAgDYkg8/SviOiIjVC0/381wAgC5si4j/D9xXpnG0bKuAAAAAAElFTkSuQmCC"
}
]
};
const salePhase = {
"type": "random",
"total_tokens": 2,
"reservation_time": 300,
"price_tiers": [{
"name": "Silver plan",
"quantity": 1,
"supply": 1,
"price": 10000000
},{
"name": "Golden plan",
"quantity": 1,
"supply": 1,
"price": 15000000
}]
};
async function getCollection() {
try {
console.log("here");
const response = await axios.get('/nft/collections');
console.log(response.data);
} catch (error) {
console.error(error);
}
}
async function createCollection(collection) {
try {
const response = await axios.post('/nft/collections', JSON.stringify(collection));
console.log(response.data);
return response.data.id;
} catch (error) {
console.error(error);
}
}
async function createTokens(collectionId, tokens) {
try {
const response = await axios.post(`/nft/collections/${collectionId}/tokens`, JSON.stringify(tokens));
console.log(response.data);
} catch (error) {
console.error(error);
}
}
async function createSalePhase(collectionId, salePhase) {
try {
console.log("Create collection");
const response = await axios.post(`/nft/collections/${collectionId}/phases`, JSON.stringify(salePhase));
return response.data;
} catch (error) {
console.error(error);
}
}
async function main(){
let collectionId = await createCollection(collection);
let tokens = await createTokens(collectionId, tokensArr);
let phase = await createSalePhase(collectionId, salePhase);
console.log(phase);
}
main();