-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodeBurn.py
51 lines (42 loc) · 1.17 KB
/
nodeBurn.py
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
import requests
import json
from dotenv import load_dotenv
import os
load_dotenv()
NODE_IP = os.getenv("NODE_IP_BURN")
API_KEY = os.getenv("API_KEY_BURN")
PW = os.getenv("PW_BURN")
def burnNft(tokenId, amount): # burns NFT using node API methods
unlockWallet()
headers = {
'accept': 'application/json',
'api_key': API_KEY,
'Content-Type': 'application/json'
}
out = {
"requests": [
{
"assetsToBurn": [
{
"tokenId": tokenId,
"amount": amount
}
]
}
],
"fee": 1000000
}
tx_id = requests.post('http://{}/wallet/transaction/send'.format(NODE_IP), headers=headers,
data=json.dumps(out)).json()
return tx_id
def unlockWallet(): # unlocks node wallet
headers = {
'accept': 'application/json',
'api_key': API_KEY,
'Content-Type': 'application/json'
}
out = {
"pass": PW
}
resp = requests.post('http://{}/wallet/unlock'.format(NODE_IP), headers=headers, data=json.dumps(out)).json()
return resp