-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc.js
More file actions
45 lines (40 loc) · 1.09 KB
/
Copy pathsrc.js
File metadata and controls
45 lines (40 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const axios = require('axios');
// Set up the Counterparty API endpoint
const CP_API = 'http://localhost:14000/api/';
// Create a new asset
const asset_name = 'MyNFT';
const asset_description = 'My first NFT on Counterparty';
const asset_data = {
artist: 'John Smith',
year: 2023,
medium: 'Oil on canvas'
};
const issuance_data = {
source: 'myaddress',
asset: asset_name,
quantity: 1,
description: asset_description,
divisible: false,
callable_: false,
transfer_destination: 'myaddress',
data: asset_data
};
axios.post(CP_API + 'create_issuance', issuance_data)
.then(response => {
console.log('Asset created:', response.data);
// Issue the new asset
const tx_data = {
tx_hex: response.data,
allow_unconfirmed_inputs: true
};
axios.post(CP_API + 'send_tx', tx_data)
.then(response => {
console.log('Asset issued:', response.data);
})
.catch(error => {
console.error('Error issuing asset:', error.response.data);
});
})
.catch(error => {
console.error('Error creating asset:', error.response.data);
});