-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.service.ts
64 lines (56 loc) · 1.99 KB
/
app.service.ts
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
import {Injectable, UnauthorizedException} from '@nestjs/common';
import axios from 'axios';
import * as Tatum from '@tatumio/tatum';
const PRIVATE_KEYS = {
[Tatum.Currency.MATIC]:
'0x37b091fc4ce46a56da643f021254612551dbe0944679a6e09cb5724d3085c9ab',
[Tatum.Currency.BSC]:
'0x37b091fc4ce46a56da643f021254612551dbe0944679a6e09cb5724d3085c9ab',
[Tatum.Currency.FLOW]:
'3881849dd540a0c80383c3727951d35e3e9e8c238ec82a581726c3fc2ca17bc4',
};
const RECIPIENT = {
[Tatum.Currency.MATIC]: '0x80d8bac9a6901698b3749fe336bbd1385c1f98f2',
[Tatum.Currency.BSC]: '0x80d8bac9a6901698b3749fe336bbd1385c1f98f2',
[Tatum.Currency.FLOW]: '0x10247089e55180c9',
};
const NFT_ADDRESS = {
[Tatum.Currency.MATIC]: '0x6d8eae641416B8b79e0fB3a92b17448CfFf02b11',
[Tatum.Currency.BSC]: '0x6d8eae641416B8b79e0fB3a92b17448CfFf02b11',
[Tatum.Currency.FLOW]: '2d103773-50e2-4a37-ac3d-61bc6af8faee',
};
const SENDER_ADDRESS = {
[Tatum.Currency.MATIC]: undefined,
[Tatum.Currency.BSC]: undefined,
[Tatum.Currency.FLOW]: '0x10247089e55180c9',
};
@Injectable()
export class AppService {
async createNFT(
file: Buffer,
name: string,
description: string,
chain: Tatum.Currency,
token: string
) {
const {data} = await axios.post(`https://www.google.com/recaptcha/api/siteverify?response=${token}&secret=6LeuI-UUAAAAAPiX-a2SVt2ew7iI_fBOVTTTDjkp`);
if (!data.success) {
throw new UnauthorizedException('Invalid recaptcha');
}
console.log(`Minting new NFT token on ${chain}.`);
return await Tatum.createNFT(
true,
{
to: RECIPIENT[chain],
contractAddress: NFT_ADDRESS[chain],
account: SENDER_ADDRESS[chain],
chain,
tokenId: `${Date.now()}`,
fromPrivateKey: PRIVATE_KEYS[chain],
} as any,
file,
name,
description,
);
}
}