-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenseed_token.py
executable file
·162 lines (132 loc) · 4.3 KB
/
openseed_token.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/python
import mysql.connector
import hashlib
import random
import sys
sys.path.append("..")
import openseed_seedgenerator as Seed
from hive import hive
thenodes = ['anyx.io','api.steem.house','hive.anyx.io','steemd.minnowsupportproject.org','steemd.privex.io']
s = hive.Hive(nodes=thenodes)
import openseed_setup as Settings
settings = Settings.get_settings()
def create_ft(devpub,apppub,devpriv,apppriv,total,fixed):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
start = hashlib.md5(str(devpub+apppub+devpriv+apppriv).encode()).hexdigest()
num = 0
while num < int(total) * int(fixed)+1:
hextoInt = int(start, 16)
newtoken = hextoInt * (num+1)
inttoHex = hex(newtoken)[2:]
token = hashlib.md5(str(inttoHex).encode()).hexdigest()
print(token)
num += 1
return
def send_ft():
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
return
def buy_ft():
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
return
def sell_ft():
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
return
#Using the schema id we generate the token.
def create_nft(schema_id):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
mysearch = openseed.cursor()
search = "SELECT title,duration,genre,date,curation FROM `audio` WHERE `ipfs`='"+str(ipfs)+"'"
mysearch.execute(search)
song = mysearch.fetchall()
result = len(song)
sql = ""
values = ""
return
def buy_nft(tokenId,account,price):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
mysearch = openseed.cursor()
search = "SELECT title,duration,genre,date,curation FROM `audio` WHERE `ipfs`='"+str(ipfs)+"'"
mysearch.execute(search)
song = mysearch.fetchall()
result = len(song)
sql = ""
values = ""
return
def sell_nft(tokenId,account,price):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
mysearch = openseed.cursor()
search = "SELECT title,duration,genre,date,curation FROM `audio` WHERE `ipfs`='"+str(ipfs)+"'"
mysearch.execute(search)
song = mysearch.fetchall()
result = len(song)
sql = ""
values = ""
return
# Trades are handled user acount to account where the account asking must own "this_tokenId" but not the "for_tokenId". Once a trade has started the asset is locked until the response comes in. The owners of either token can cancel or deny the trade but cannot trade the asset multiple times.
def trade_nft(this_tokenId,account,for_tokenId,response):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
mysearch = openseed.cursor()
search = "SELECT title,duration,genre,date,curation FROM `audio` WHERE `ipfs`='"+str(ipfs)+"'"
mysearch.execute(search)
song = mysearch.fetchall()
result = len(song)
sql = ""
values = ""
return
# The NFT Schema is used to create the NFTs on demand. The record is kept on OpenSeeds server but could be shared on steem at a later date.
# The unique_data field will be used for the tokens unique fields. In the case of the schema these will be structured like this {<var name>:{begin:<num>,end:<num>}} the generator will read these keys and generate a value for the variable name in the final token.
def create_nft_schema(creator_id,version,type,preview,asset,unique_data,discription,upgradeable,license,license_file,total_available):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
mysearch = openseed.cursor()
search = "SELECT title,duration,genre,date,curation FROM `audio` WHERE `ipfs`='"+str(ipfs)+"'"
mysearch.execute(search)
song = mysearch.fetchall()
result = len(song)
sql = ""
values = ""
return