-
Notifications
You must be signed in to change notification settings - Fork 5
/
fastMint.js
75 lines (59 loc) · 1.98 KB
/
fastMint.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const express = require('express')
var parseUrl = require('body-parser')
const API_KEY = 'YOUR API KEY GOES HERE';
const app = express()
let encodeUrl = parseUrl.urlencoded({ extended: false })
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
var multipart = require('connect-multiparty')
var multipartmiddleware = multipart();
app.get('/image', (req, res) => {
res.sendFile(__dirname + '/form.html')
})
app.post('/image',multipartmiddleware, (req, res) => {
// axios
var data = new FormData();
data.append('allowPlatformToOperateToken', req.body.allowPlatformToOperateToken);
data.append('chain', req.body.chain);
data.append('recipientAddress', req.body.recipientAddress);
data.append('filePath', fs.createReadStream(req.files.filePath.path));
data.append('name', req.body.name);
data.append('description', req.body.description);
var config = {
method: 'post',
url: 'https://api.verbwire.com/v1/nft/mint/quickMintFromFile',
headers: {
'X-API-Key': API_KEY,
...data.getHeaders()
},
data : data
};
console.log("data",data);
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
res.send(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error);
});
})
app.get('/url', (req, res) => {
res.sendFile(__dirname + '/form2.html')
})
app.post('/url', encodeUrl, (req, res) => {
console.log('Form request:', req.body)
const sdk = require('api')('@verbwire/v1.0#hr2s143dl9hbr7s9');
sdk.auth(API_KEY);
sdk.post('/nft/mint/quickMintFromMetadataUrl', {
allowPlatformToOperateToken: req.body.allowPlatformToOperateToken,
chain: req.body.chain,
metadataUrl: req.body.url,
description: req.body.name,
recipientAddress: req.body.recipientAddress,
}, {accept: 'application/json'})
.then(resp => res.send(resp))
.catch(err => console.error(err));
})
app.listen(8080)