-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenseed_nft.py
115 lines (91 loc) · 3.32 KB
/
openseed_nft.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
#!/usr/bin/python
import mysql.connector
import hashlib
import random
import sys
sys.path.append("..")
import openseed_seedgenerator as Seed
from steem import Steem
thenodes = ['anyx.io','api.steem.house','hive.anyx.io','steemd.minnowsupportproject.org','steemd.privex.io']
s = Steem()
import openseed_setup as Settings
settings = Settings.get_settings()
#Using the schema id we generate the token.
def create_nft(schema_id):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["ipfsuser"],
password = settings["ipfspassword"],
database = "ipfsstore"
)
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["ipfsuser"],
password = settings["ipfspassword"],
database = "ipfsstore"
)
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 sale_nft(tokenId,account,price):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["ipfsuser"],
password = settings["ipfspassword"],
database = "ipfsstore"
)
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["ipfsuser"],
password = settings["ipfspassword"],
database = "ipfsstore"
)
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["ipfsuser"],
password = settings["ipfspassword"],
database = "ipfsstore"
)
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