-
Notifications
You must be signed in to change notification settings - Fork 1
/
node.py
57 lines (47 loc) · 1.38 KB
/
node.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
51
52
53
54
55
import requests
import json
from dotenv import load_dotenv
import os
load_dotenv()
NODE_IP = os.getenv("NODE_IP")
API_KEY = os.getenv("API_KEY")
PW = os.getenv("PW")
WALLET_ADDRESS = os.getenv("WALLET_ADDRESS")
def mintNft(name, description, encodedHash, encodedLink): # mints NFT through node API requests
unlockWallet()
headers = {
'accept': 'application/json',
'api_key': API_KEY,
'Content-Type': 'application/json'
}
out = {
"requests": [
{
"address": WALLET_ADDRESS,
"amount": 1,
"name": name,
"description": description,
"decimals": 0,
"registers": {
"R7": "0e020101",
"R8": encodedHash,
"R9": encodedLink
}
}
],
"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