Tangocrypto
Search…
Tutorial

Step 1: Create an NFT collection

Create collection request
HTTP
cURL
NodeJs
1
POST /<app-id>/v1/nft/collections HTTP/1.1
2
Host: cardano-testnet.tangocrypto.com
3
x-api-key: <your-api-key>
4
Content-Type: application/json
5
​
6
{
7
"name": "Tangocrypto Collection",
8
"description": "Tangocrypto collection description",
9
"url": "https://www.tangocrypto.com",
10
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
11
"policy": {
12
"lock": true,
13
"lock_time": "2022-02-24"
14
15
},
16
"metadata": {
17
"name": "<name>",
18
"asset_name": "<asset_name>",
19
"media_type": "<mime_type>",
20
"description": "<description>",
21
"files": [
22
{
23
"name": "<asset_name>",
24
"media_type": "<mime_type>",
25
"src": "<file_link>"
26
}
27
],
28
"attributes": {
29
"color": "<color>",
30
"body": "<body>",
31
"eyes": "<eyes>",
32
"face": "<face>",
33
"accessory": "<accessory>",
34
"collection": "Tangocrypto Collection",
35
"artist": "Tangocrypto",
36
"twitter": "https://twitter.com/tango_crypto",
37
"website": "https://www.tangocrypto.com",
38
"copyright": "Tangocrypto 2022"
39
},
40
"version": "1.0"
41
}
42
}
Copied!
1
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections' \
2
--header 'x-api-key: <your-api-key>' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"name": "Tango Collection",
6
"description": "Tango collection description",
7
"url": "https://www.tangocrypto.com",
8
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
9
"policy": {
10
"lock": true,
11
"lock_time": "2022-02-24"
12
},
13
"metadata": {
14
"asset_name": "<asset_name>",
15
"name": "<name>",
16
"media_type": "<mime_type>",
17
"description": "<description>",
18
"files": [
19
{
20
"name": "<asset_name>",
21
"media_type": "<mime_type>",
22
"src": "<file_link>"
23
}
24
],
25
"attributes": {
26
"color": "<color>",
27
"body": "<body>",
28
"eyes": "<eyes>",
29
"face": "<face>",
30
"accessory": "<accessory>",
31
"collection": "Tangocrypto Collection",
32
"artist": "Tangocrypto",
33
"twitter": "https://twitter.com/tango_crypto",
34
"copyright": "Tangocrypto 2022"
35
},
36
"version": "1.0"
37
}
38
}'
Copied!
1
var axios = require('axios');
2
var data = JSON.stringify({
3
"name": "Tango Collection",
4
"description": "Tango collection description",
5
"url": "https://www.tangocrypto.com",
6
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
7
"policy": {
8
"lock": true,
9
"lock_time": "2022-02-24"
10
},
11
"metadata": {
12
"name": "<name>",
13
"asset_name": "<asset_name>",
14
"media_type": "<mime_type>",
15
"description": "<description>",
16
"files": [
17
{
18
"name": "<asset_name>",
19
"media_type": "<mime_type>",
20
"src": "<file_link>"
21
}
22
],
23
"attributes": {
24
"color": "<color>",
25
"body": "<body>",
26
"eyes": "<eyes>",
27
"face": "<face>",
28
"accessory": "<accessory>",
29
"collection": "Tangocrypto Collection",
30
"artist": "Tangocrypto",
31
"twitter": "https://twitter.com/tango_crypto",
32
"copyright": "Tangocrypto 2022"
33
},
34
"version": "1.0"
35
}
36
});
37
​
38
var config = {
39
method: 'post',
40
url: 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections',
41
headers: {
42
'x-api-key': '<your-api-key>',
43
'Content-Type': 'application/json'
44
},
45
data: data
46
};
47
​
48
axios(config)
49
.then(function (response) {
50
console.log(JSON.stringify(response.data));
51
})
52
.catch(function (error) {
53
console.log(error);
54
});
55
​
Copied!
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.
1
{
2
"id": "e1d7fe1d97c64518a5c51011edcc1a31",
3
"name": "Tango Collection",
4
"url": "https://www.tangocrypto.com",
5
"description": "Tango collection description",
6
"payout_address": "addr_test1qpp33lzjgyzz6k86yy27kvkjepu8mfjy6g4l8rf2v8yjp4sla7h6txtvlevazp6jylz0w90y8yz0uec3cder28r47sssj9w2kd",
7
"token_count": 0,
8
"token_for_sale_count": 0,
9
"token_sold_count": 0,
10
"revenue": 0,
11
"income": 0,
12
"service_fee": 0,
13
"nft_fee": 0,
14
"tx_fee": 0,
15
"total_fees": 0,
16
"policy": {
17
"lock": true,
18
"lock_time": "2022-02-24T00:00:00.000Z",
19
"policy_id": "6a16d7d312dfcbcb4f676fa31893cf6c456508d84472309f3aa7c998",
20
"script": {
21
"type": "all",
22
"scripts": [
23
{
24
"type": "sig",
25
"keyHash": "76bcc8cf947649636f027e705a30ec66fa0476971aef51d219323c07"
26
},
27
{
28
"type": "before",
29
"slot": 54094491
30
}
31
]
32
}
33
},
34
"metadata": {
35
"label": "721",
36
"asset_name": "<asset_name>",
37
"name": "<name>",
38
"media_type": "<mime_type>",
39
"description": "<description>",
40
"files": [
41
{
42
"name": "<asset_name>",
43
"media_type": "<mime_type>",
44
"src": "<file_link_1>"
45
}
46
],
47
"attributes": {
48
"color": "<color>",
49
"body": "<body>",
50
"eyes": "<eyes>",
51
"face": "<face>",
52
"accessory": "<accessory>",
53
"collection": "Tangocrypto Collection",
54
"artist": "Tangocrypto",
55
"twitter": "https://twitter.com/tango_crypto",
56
"website": "https://www.tangocrypto.com",
57
"copyright": "Tangocrypto 2022"
58
},
59
"version": "1.0"
60
},
61
"created_at": "2022-02-23T08:21:38.908Z",
62
"updated_at": "2022-02-23T08:21:38.908Z"
63
}
Copied!

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
1
POST /<app-id>/v1/nft/collections/<collection-id>/tokens HTTP/1.1
2
Host: cardano-testnet.tangocrypto.com
3
x-api-key: <your-api-key>
4
Content-Type: application/json
5
​
6
{
7
"tokens": [{
8
"name": "Tango 01",
9
"asset_name": "Tango01",
10
"description": "If you get all tangled up, just tango on.",
11
"media_type": "image/png",
12
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
13
"metadata_attributes": [{
14
"tag": "<color>",
15
"value": "Blue"
16
},
17
{
18
"tag": "<body>",
19
"value": "Skinny"
20
},
21
{
22
"tag": "<eyes>",
23
"value": "Blue"
24
},
25
{
26
"tag": "<face>",
27
"value": "rounded"
28
},
29
{
30
"tag": "<accessory>",
31
"value": "keyboard"
32
}
33
],
34
"custom_attributes": {
35
"serial_no": "12345545",
36
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
37
}
38
}]
39
}
Copied!
1
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/tokens' \
2
--header 'x-api-key: <your-api-key>' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"tokens": [{
6
"name": "Tango 01",
7
"asset_name": "Tango01",
8
"description": "If you get all tangled up, just tango on.",
9
"media_type": "image/png",
10
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
11
"metadata_attributes": [{
12
"tag": "<color>",
13
"value": "Blue"
14
},
15
{
16
"tag": "<body>",
17
"value": "Skinny"
18
},
19
{
20
"tag": "<eyes>",
21
"value": "Blue"
22
},
23
{
24
"tag": "<face>",
25
"value": "rounded"
26
},
27
{
28
"tag": "<accessory>",
29
"value": "keyboard"
30
}
31
​
32
],
33
"custom_attributes": {
34
"serial_no": "12345545",
35
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
36
}
37
}]
38
}'
Copied!
1
var axios = require('axios');
2
var data = JSON.stringify({
3
"tokens": [{
4
"name": "Tango 01",
5
"asset_name": "Tango01",
6
"description": "If you get all tangled up, just tango on.",
7
"media_type": "image/png",
8
"image": "iVBORw0KGgoAAAANSU.....hEUgAADQYAAA0HCAYAAACB0xAqAAAACXBIWXMA",
9
"metadata_attributes": [{
10
"tag": "<color>",
11
"value": "Blue"
12
},
13
{
14
"tag": "<body>",
15
"value": "Skinny"
16
},
17
{
18
"tag": "<eyes>",
19
"value": "Blue"
20
},
21
{
22
"tag": "<face>",
23
"value": "rounded"
24
},
25
{
26
"tag": "<accessory>",
27
"value": "keyboard"
28
}
29
],
30
"custom_attributes": {
31
"serial_no": "12345545",
32
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
33
}
34
}]
35
});
36
​
37
var config = {
38
method: 'post',
39
url: 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/tokens',
40
headers: {
41
'x-api-key': '<your-api-key>',
42
'Content-Type': 'application/json'
43
},
44
data : data
45
};
46
​
47
axios(config)
48
.then(function (response) {
49
console.log(JSON.stringify(response.data));
50
})
51
.catch(function (error) {
52
console.log(error);
53
});
54
​
Copied!
Response
1
{
2
"data": [
3
{
4
"id": "e9e00b33e0a34edcaf4534a2f96a637d",
5
"asset_name": "Tango01",
6
"name": "Tango 01",
7
"fingerprint": "asset1hzh0uut85ypcueu88422pmgf6twzj2c52f73a5",
8
"status": "FOR_SALE",
9
"description": "If you get all tangled up, just tango on.",
10
"image": "ipfs://QmP8uBgxmTpduCUbasQRCEpiq1g9KEjxuRfR5VcvifWoNo",
11
"media_type": "image/png",
12
"metadata_attributes": [
13
{
14
"name": "Attribute color",
15
"value": "Blue",
16
"tag": "<color>"
17
},
18
{
19
"name": "Attribute body",
20
"value": "Skinny",
21
"tag": "<body>"
22
},
23
{
24
"name": "Attribute eyes",
25
"value": "Green",
26
"tag": "<eyes>"
27
},
28
{
29
"name": "Attribute face",
30
"value": "Rounded",
31
"tag": "<face>"
32
},
33
{
34
"name": "Attribute accessory",
35
"value": "Keyboard",
36
"tag": "<accessory>"
37
}
38
],
39
"custom_attributes": {
40
"serial_no": "12345545",
41
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
42
},
43
"policy": {
44
"lock": true,
45
"lock_time": "2022-01-03T15:35:10.000Z",
46
"policy_id": "1373bf16cdea380e6c9c716d0f56f021b9e9ddea90b248dae6310d95",
47
"script": {
48
"type": "all",
49
"scripts": [
50
{
51
"type": "sig",
52
"keyHash": "ac1746df0ba039de81274d472a477fced610f57cebc5c7841074f54c"
53
},
54
{
55
"type": "before",
56
"slot": "46854826"
57
}
58
]
59
}
60
},
61
"metadata": {
62
"721": {
63
"1373bf16cdea380e6c9c716d0f56f021b9e9ddea90b248dae6310d95": {
64
"Tango01": {
65
"name": "Tango 01",
66
"description": "If you get all tangled up, just tango on.",
67
"image": "ipfs://QmP8uBgxmTpduCUbasQRCEpiq1g9KEjxuRfR5VcvifWoNo",
68
"mediaType": "image/png",
69
"color": "Blue",
70
"body": "Skinny",
71
"eyes": "Green",
72
"face": "Rounded",
73
"accessory": "Keyboard",
74
"collection": "Tangocrypto Collection",
75
"artist": "Tangocrypto",
76
"twitter": "https://twitter.com/tango_crypto",
77
"website": "https://www.tangocrypto.com",
78
"copyright": "Tangocrypto 2022",
79
"serial_no": "12345545",
80
"md5checksum": "bc527343c7ffc103111f3a694b004e2f"
81
82
}
83
},
84
"version": "1.0"
85
}
86
},
87
"created_at": "2021-11-30T23:17:36.791Z",
88
"updated_at": "2021-11-30T23:17:36.791Z"
89
}
90
],
91
"status_code": 201
92
}
Copied!

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
1
POST /<app-id>/v1/nft/collections/<collection-id>/phases HTTP/1.1
2
Host: cardano-testnet-staging.tangocrypto.com
3
x-api-key: <your-api-key>
4
Content-Type: application/json
5
Content-Length: 662
6
​
7
{
8
"name": "pre-sale",
9
"type": "random",
10
"total_tokens": 1000,
11
"reservation_time": 300,
12
"price_tiers": [
13
{
14
"name": "Bronze",
15
"quantity": 1,
16
"supply": 1,
17
"price": 10000000
18
},
19
{
20
"name": "Silver",
21
"quantity": 2,
22
"supply": 1,
23
"price": 20000000
24
},
25
{
26
"name": "Gold",
27
"quantity": 4,
28
"supply": 1,
29
"price": 30000000
30
},
31
{
32
"name": "Platinum",
33
"quantity": 8,
34
"supply": 1,
35
"price": 60000000
36
}
37
]
38
}
Copied!
1
curl --location --request POST 'https://cardano-mainnet.tangocrypto.com/<app-id>/v1/nft/collections/<collection-id>/phases' \
2
--header 'x-api-key: <your-api-key>' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"name": "pre-sale",
6
"type": "random",
7
"total_tokens": 1000,
8
"reservation_time": 300,
9
"price_tiers": [
10
{
11
"name": "Bronze",
12
"quantity": 1,
13
"supply": 1,
14
"price": 10000000
15
},
16
{
17
"name": "Silver",
18
"quantity": 2,
19
"supply": 1,
20
"price": 20000000
21
},
22
{
23
"name": "Gold",
24
"quantity": 4,
25
"supply": 1,
26
"price": 30000000
27
},
28
{
29
"name": "Platinum",
30
"quantity": 8,
31
"supply": 1,
32
"price": 60000000
33
}
34
]
35
}'
Copied!
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.
1
{
2
"id": "81d190a7ed1847cc97cf515aa2a70bc2",
3
"type": "random",
4
"name": "pre-sale",
5
"active": true,
6
"reservation_time": 300,
7
"total_tokens": 1000,
8
"remaining_tokens": 1000,
9
"price_tiers": [
10
{
11
"id": 0,
12
"name": "Bronze",
13
"price": 10000000,
14
"quantity": 1,
15
"supply": 1,
16
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MTAwMDAwMDAsInByaWNlX2lkIjowLCJxdWFudGl0eSI6MSwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
17
},
18
{
19
"id": 1,
20
"name": "Silver",
21
"price": 20000000,
22
"quantity": 2,
23
"supply": 1,
24
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MjAwMDAwMDAsInByaWNlX2lkIjoxLCJxdWFudGl0eSI6Miwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
25
},
26
{
27
"id": 2,
28
"name": "Gold",
29
"price": 30000000,
30
"quantity": 4,
31
"supply": 1,
32
"payment_link": "https://buy.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6MzAwMDAwMDAsInByaWNlX2lkIjoyLCJxdWFudGl0eSI6NCwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
33
},
34
{
35
"id": 3,
36
"name": "Platinum",
37
"price": 60000000,
38
"quantity": 8,
39
"supply": 1,
40
"payment_link": "https://by.tangocrypto.com?q=test_eyJjb2xsZWN0aW9uX2lkIjoiOTFjMjYyZmRkYjljNGYyOWJmZDc0MTI1NmJmMzAxMWIiLCJwaGFzZV9pZCI6IjgxZDE5MGE3ZWQxODQ3Y2M5N2NmNTE1YWEyYTcwYmMyIiwicnVsZXMiOltdLCJwcmljZSI6NjAwMDAwMDAsInByaWNlX2lkIjozLCJxdWFudGl0eSI6OCwic3VwcGx5IjoxLCJ0eXBlIjoiUGhhc2VTYWxlIiwidGNjIjoicVgrcGdJUm00Qm5iVVR2UnFzeGtmK3p4VVBoeFUzaE1rRGVqMTdTSGlwckZMd1BkOGpwaTRleDFCQ2d3YXFyUUpRUEd6SFVVdm9BdEdPbU14dUlYY25LU09rVzkxRVZ1YnhhajdwVDRETVVpaU9NZXdIRXV3eHJUVndQVkFnPT0ifQ=="
41
}
42
],
43
"created_at": "2022-05-24T03:10:58.988Z",
44
"updated_at": "2022-05-24T03:10:58.988Z"
45
}
Copied!

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.
1
const axios = require('axios').default;
2
​
3
const HOST = 'cardano-testnet.tangocrypto.com';
4
const APP_ID = '34492bb302cf4678a3a0ec93029c5bh67';
5
const API_KEY = '8888c8026e7i47b4b2527151e126e914';
6
​
7
axios.defaults.baseURL = `https://${HOST}/${APP_ID}/v1`;
8
axios.defaults.headers.common['x-api-key'] = API_KEY;
9
axios.defaults.headers.post['Content-Type'] = 'application/json';
10
​
11
const collection = {
12
"name": "Tango Collection",
13
"description": "Tango collection description",
14
"url": "https://www.tangocrypto.com",
15
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
16
"policy": {
17
"lock": true,
18
"lock_time": "2023-02-24"
19
},
20
"metadata": {
21
"asset_name": "<asset_name>",
22
"name": "<name>",
23
"image": "<image_link>",
24
"media_type": "<mime_type>",
25
"description": "<description>",
26
"attributes": {
27
"color": "<color>",
28
"right_eye": "<right_eye>",
29
"left_eye": "<left_eye>",
30
"mouth": "<mouth>",
31
"collection": "Faces Collection",
32
"artist": "Tangocrypto",
33
"twitter": "https://twitter.com/tango_crypto",
34
"copyright": "Tangocrypto 2022"
35
},
36
"version": "1.0"
37
}
38
};
39
​
40
const tokensArr = {
41
"tokens": [
42
{
43
"asset_name": "FACE#01",
44
"name": "FACE#01",
45
"description": "Faces collection",
46
"media_type": "png",
47
"custom_attributes": {
48
"md5checksum": "b58e62a83802b2bf0792a4e983dd2ff3cf9e0c1e"
49
},
50
"metadata_attributes": [
51
{
52
"tag": "<color>",
53
"name": "Attribute color",
54
"value": "Light Blue"
55
},
56
{
57
"tag": "<left_eye>",
58
"name": "Attribute left eye",
59
"value": "Open"
60
},
61
{
62
"tag": "<right_eye>",
63
"name": "Attribute right eye",
64
"value": "Half"
65
},
66
{
67
"tag": "<mouth>",
68
"name": "Attribute mouth",
69
"value": "Astonishmed"
70
}
71
],
72
"image": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAABCRB0AEiAAECDoAJEDQ...A0ACBB0AEiDoAJAAQQeABPQu/W2h2FEAAMuy8PeE90ZE/PmXzxU5FgCgCT0R8f8BA0CEYwSaYAIAAAAASUVORK5CYII="
73
},
74
{
75
"asset_name": "FACE#02",
76
"name": "FACE#02",
77
"description": "Faces collection",
78
"media_type": "png",
79
"custom_attributes": {
80
"md5checksum": "bee6ddb26d7d9b5f7dccba997ec575d272d6981f"
81
},
82
"metadata_attributes": [
83
{
84
"tag": "<color>",
85
"name": "Attribute color",
86
"value": "Light Purple"
87
},
88
{
89
"tag": "<left_eye>",
90
"name": "Attribute left eye",
91
"value": "Closed"
92
},
93
{
94
"tag": "<right_eye>",
95
"name": "Attribute right eye",
96
"value": "Half"
97
},
98
{
99
"tag": "<mouth>",
100
"name": "Attribute mouth",
101
"value": "Happy"
102
}
103
],
104
"image": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KA.....IQdABIQNABIAFBB4AEBB0AEhB0AEhA0AEgAUEHgAR2tP/0YX/PAgDYkg8/SviOiIjVC0/381wAgC5si4j/D9xXpnG0bKuAAAAAAElFTkSuQmCC"
105
}
106
]
107
};
108
​
109
const salePhase = {
110
"type": "random",
111
"total_tokens": 2,
112
"reservation_time": 300,
113
"price_tiers": [{
114
"name": "Silver plan",
115
"quantity": 1,
116
"supply": 1,
117
"price": 10000000
118
},{
119
"name": "Golden plan",
120
"quantity": 1,
121
"supply": 1,
122
"price": 15000000
123
}]
124
};
125
​
126
async function getCollection() {
127
try {
128
console.log("here");
129
const response = await axios.get('/nft/collections');
130
console.log(response.data);
131
} catch (error) {
132
console.error(error);
133
}
134
}
135
​
136
async function createCollection(collection) {
137
try {
138
const response = await axios.post('/nft/collections', JSON.stringify(collection));
139
console.log(response.data);
140
return response.data.id;
141
} catch (error) {
142
console.error(error);
143
}
144
}
145
​
146
async function createTokens(collectionId, tokens) {
147
try {
148
const response = await axios.post(`/nft/collections/${collectionId}/tokens`, JSON.stringify(tokens));
149
console.log(response.data);
150
} catch (error) {
151
console.error(error);
152
}
153
}
154
​
155
async function createSalePhase(collectionId, salePhase) {
156
try {
157
console.log("Create collection");
158
const response = await axios.post(`/nft/collections/${collectionId}/phases`, JSON.stringify(salePhase));
159
return response.data;
160
} catch (error) {
161
console.error(error);
162
}
163
}
164
​
165
async function main(){
166
let collectionId = await createCollection(collection);
167
let tokens = await createTokens(collectionId, tokensArr);
168
let phase = await createSalePhase(collectionId, salePhase);
169
console.log(phase);
170
}
171
​
172
main();
Copied!