8 | | - | let c = "price" |
---|
9 | | - | |
---|
10 | | - | let d = "sell" |
---|
11 | | - | |
---|
12 | | - | let e = 30 |
---|
13 | | - | |
---|
14 | | - | let f = base58'2GRRVTq1EzVDGMC1XQ5zfa73TVVfDtuEXQs9z1Fek9QjkD' |
---|
15 | | - | |
---|
16 | | - | let g = base58'' |
---|
17 | | - | |
---|
18 | | - | let h = "bid" |
---|
19 | | - | |
---|
20 | | - | let i = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED") |
---|
21 | | - | |
---|
22 | | - | let j = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq' |
---|
23 | | - | |
---|
24 | | - | func k (l) = { |
---|
25 | | - | let m = assetInfo(l) |
---|
26 | | - | if ($isInstanceOf(m, "Asset")) |
---|
27 | | - | then { |
---|
28 | | - | let n = m |
---|
29 | | - | if (if ((n.decimals == 0)) |
---|
30 | | - | then (n.quantity == 1) |
---|
31 | | - | else false) |
---|
32 | | - | then (n.reissuable == false) |
---|
33 | | - | else false |
---|
34 | | - | } |
---|
35 | | - | else false |
---|
36 | | - | } |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | @Callable(o) |
---|
40 | | - | func createNft (p,q,r,s,t,u,v,w,x) = { |
---|
41 | | - | let y = Issue(p, v, 1, 0, false) |
---|
42 | | - | let z = calculateAssetId(y) |
---|
43 | | - | let A = o.transactionId |
---|
44 | | - | [y, ScriptTransfer(o.caller, 1, z), StringEntry(((toBase58String(z) + a) + "Owner"), toString(o.caller)), StringEntry(((toBase58String(z) + a) + "nft_type"), s), StringEntry(((toBase58String(z) + a) + "nft_tags"), t), StringEntry(((toBase58String(z) + a) + "nft_dAppAddress"), r), IntegerEntry(((toBase58String(z) + a) + "nft_selling_price"), u), StringEntry(((toBase58String(z) + a) + "nft_onSell"), w), StringEntry(((toBase58String(z) + a) + "nft_data"), x), StringEntry(((toBase58String(A) + a) + "issue_nft"), toBase58String(z))] |
---|
45 | | - | } |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | @Callable(o) |
---|
50 | | - | func sellNFT (B,C) = { |
---|
51 | | - | let A = o.transactionId |
---|
52 | | - | let D = o.caller.bytes |
---|
53 | | - | let E = $Tuple2(value(o.payments[0].assetId), value(o.payments[0].amount)) |
---|
54 | | - | let F = E._1 |
---|
55 | | - | let G = E._2 |
---|
56 | | - | if (!(k(F))) |
---|
57 | | - | then throw("Token is not NFT") |
---|
58 | | - | else [StringEntry(((c + a) + toBase58String(value(o.payments[0].assetId))), B), StringEntry(((toString(o.caller) + a) + d), (((toBase58String(F) + a) + toString(G)) + C))] |
---|
59 | | - | } |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | @Callable(o) |
---|
64 | | - | func buyNFT (H,I) = { |
---|
65 | | - | let l = fromBase58String(H) |
---|
66 | | - | let J = value(o.payments[0].amount) |
---|
67 | | - | let K = { |
---|
68 | | - | let m = getString(this, (("nft_" + I) + "_owner")) |
---|
69 | | - | if ($isInstanceOf(m, "String")) |
---|
70 | | - | then { |
---|
71 | | - | let L = m |
---|
72 | | - | L |
---|
73 | | - | } |
---|
74 | | - | else false |
---|
75 | | - | } |
---|
76 | | - | let B = getStringValue(((((c + a) + H) + "_") + I)) |
---|
77 | | - | let M = ((J / 1000) * 975) |
---|
78 | | - | let N = ((J / 1000) * 25) |
---|
79 | | - | if ((I == toString(o.caller))) |
---|
80 | | - | then throw("current Owner of NFT not able to purchase") |
---|
81 | | - | else if ((o.payments[0].assetId == f)) |
---|
82 | | - | then [ScriptTransfer(o.caller, 1, l), ScriptTransfer(Address(fromBase58String(I)), M, f), StringEntry((("nft_" + H) + "platform_fee"), toString(N)), StringEntry(((toString(o.caller) + a) + b), ((H + a) + toString(J))), DeleteEntry((("nft_" + I) + "_owner")), StringEntry((("nft_" + I) + "_owner"), toString(o.caller)), StringEntry(((H + a) + "_owner"), toString(o.caller))] |
---|
83 | | - | else if ((o.payments[0].assetId == unit)) |
---|
84 | | - | then [ScriptTransfer(o.caller, 1, l), ScriptTransfer(Address(fromBase58String(I)), M, unit), StringEntry((("nft_" + H) + "platform_fee"), toString(N)), StringEntry(((toString(o.caller) + a) + b), ((H + a) + toString(J))), DeleteEntry((("nft_" + I) + "_owner")), StringEntry((("nft_" + I) + "_owner"), toString(o.caller)), StringEntry(((H + a) + "_owner"), toString(o.caller))] |
---|
85 | | - | else nil |
---|
86 | | - | } |
---|
87 | | - | |
---|
88 | | - | |
---|
89 | | - | |
---|
90 | | - | @Callable(o) |
---|
91 | | - | func cancelSell (O) = { |
---|
92 | | - | let A = toBase58String(o.transactionId) |
---|
93 | | - | let D = o.caller.bytes |
---|
94 | | - | [StringEntry(((A + O) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(D), 1, fromBase58String(O))] |
---|
95 | | - | } |
---|
96 | | - | |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | @Callable(o) |
---|
100 | | - | func addAuction (P,Q,R,S,C) = { |
---|
101 | | - | let A = toBase58String(o.transactionId) |
---|
102 | | - | let O = value(o.payments[0].assetId) |
---|
103 | | - | let B = value(R) |
---|
104 | | - | let T = (lastBlock.height + S) |
---|
105 | | - | let U = o.caller.bytes |
---|
106 | | - | let V = { |
---|
107 | | - | let m = getString(this, (((toBase58String(O) + a) + "nft_status_") + toBase58String(U))) |
---|
108 | | - | if ($isInstanceOf(m, "String")) |
---|
109 | | - | then { |
---|
110 | | - | let L = m |
---|
111 | | - | true |
---|
112 | | - | } |
---|
113 | | - | else false |
---|
114 | | - | } |
---|
115 | | - | if ((V == true)) |
---|
116 | | - | then throw("Already in auction list") |
---|
117 | | - | else if ((S > e)) |
---|
118 | | - | then throw(("Duration is too long. Must be less than or equal to 7 " + toString(e))) |
---|
119 | | - | else if ((o.payments[0].assetId == unit)) |
---|
120 | | - | then throw("NFT not attached") |
---|
121 | | - | else if ((o.payments[0].assetId == f)) |
---|
122 | | - | then throw("NFT not attached") |
---|
123 | | - | else [StringEntry(((A + "nft_start_auction_date") + toBase58String(U)), P), StringEntry(((A + "nft_end_auction_date") + toBase58String(U)), Q), StringEntry((A + "_nft_start_price"), R), StringEntry((A + "_nft_owner"), toString(o.caller)), StringEntry((A + "_nft_on_auction"), toBase58String(O)), StringEntry((A + "_previous_bidder"), "none"), StringEntry((A + "_highest_bid"), "0"), StringEntry((A + "_winner_of_nft"), "0"), StringEntry((A + "_bidder_count"), "0"), StringEntry((A + "_nft_status"), "OPEN")] |
---|
124 | | - | } |
---|
125 | | - | |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | @Callable(o) |
---|
129 | | - | func placeBid (W,O,q,X,Y) = { |
---|
130 | | - | let A = toBase58String(o.transactionId) |
---|
131 | | - | let U = o.caller.bytes |
---|
132 | | - | let l = fromBase58String(O) |
---|
133 | | - | let Z = o.payments[0].assetId |
---|
134 | | - | let aa = o.payments[0].amount |
---|
135 | | - | let ab = getStringValue(this, (W + "_highest_bid")) |
---|
136 | | - | let ac = getString(this, (W + "_previous_bidder")) |
---|
137 | | - | let ad = getStringValue(this, (W + "_bidder_count")) |
---|
138 | | - | let ae = getStringValue(this, (W + "_winner_of_nft")) |
---|
139 | | - | let V = getStringValue(this, (W + "_nft_status")) |
---|
140 | | - | if ((V != "OPEN")) |
---|
141 | | - | then throw("Not open for auction") |
---|
142 | | - | else if ((parseIntValue(ab) >= aa)) |
---|
143 | | - | then throw("Bid is less then starting/highest Bid") |
---|
144 | | - | else if ((ab == "0")) |
---|
145 | | - | then [StringEntry((W + "_highest_bid"), toString(aa)), StringEntry((W + "_winner_of_nft"), toBase58String(o.caller.bytes)), StringEntry((W + "_bidder_count"), toString((parseIntValue(ad) + 1))), StringEntry((W + "_nft_id"), toBase58String(l)), StringEntry((W + "_nft_owner"), q), StringEntry((((A + "_") + W) + "_highest_bid"), toString(aa)), StringEntry((((A + "_") + W) + "_winner"), toBase58String(o.caller.bytes)), StringEntry((((A + "_") + W) + "_bidder_count"), toString((parseIntValue(ad) + 1))), StringEntry((((A + "_") + W) + "_nft_id"), toBase58String(l)), StringEntry((((A + "_") + W) + "_nft_owner"), q), StringEntry((A + "_bid_for_nft_by"), toBase58String(U)), StringEntry((A + "_bid_price_place"), X), StringEntry((A + "_previous_bid_amount_refund_to_address"), ae), StringEntry((A + "_prevoius_bid_amount_refund"), ab)] |
---|
146 | | - | else if ((ab != "0")) |
---|
147 | | - | then [ScriptTransfer(Address(fromBase58String(ae)), parseIntValue(ab), Z), StringEntry((A + "_previous_bid_amount_refund_to_address"), ae), StringEntry((A + "_prevoius_bid_amount_refund"), ab), StringEntry((W + "_bidder_count"), toString((parseIntValue(ad) + 1))), StringEntry((W + "_highest_bid"), toString(aa)), StringEntry((W + "_winner_of_nft"), toBase58String(o.caller.bytes)), StringEntry((W + "_nft_id"), toBase58String(l)), StringEntry((W + "_nft_owner"), q), StringEntry((((A + "_") + W) + "_highest_bid"), toString(aa)), StringEntry((((A + "_") + W) + "_winner"), toBase58String(o.caller.bytes)), StringEntry((((A + "_") + W) + "_bidder_count"), toString((parseIntValue(ad) + 1))), StringEntry((((A + "_") + W) + "_nft_id"), toBase58String(l)), StringEntry((((A + "_") + W) + "_nft_owner"), q), StringEntry((A + "_bid_for_nft_by"), toBase58String(U)), StringEntry((A + "_bid_price_place"), X)] |
---|
148 | | - | else nil |
---|
149 | | - | } |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | |
---|
153 | | - | @Callable(o) |
---|
154 | | - | func acceptBidOffer (W,O,af,Y) = { |
---|
155 | | - | let A = toBase58String(o.transactionId) |
---|
156 | | - | let U = o.caller.bytes |
---|
157 | | - | let l = fromBase58String(O) |
---|
158 | | - | let ag = getStringValue(this, (W + "_highest_bid")) |
---|
159 | | - | let ah = ((parseIntValue(ag) / 1000) * 975) |
---|
160 | | - | let N = ((parseIntValue(ag) / 1000) * 25) |
---|
161 | | - | let ai = getStringValue(this, (W + "_winner_of_nft")) |
---|
162 | | - | if ((Y == f)) |
---|
163 | | - | then [ScriptTransfer(Address(U), ah, f), ScriptTransfer(Address(fromBase58String(ai)), 1, l), StringEntry("platform_fee", toString(N)), StringEntry((A + "_amount_paid_to_owner"), ag), StringEntry((A + "_nft_transfer_to"), ai), StringEntry((A + "_nft_status"), "REWARDED"), StringEntry((W + "_amount_paid_to_owner"), ag), StringEntry((W + "_nft_transfer_to"), ai), StringEntry((W + "_nft_status"), "REWARDED")] |
---|
164 | | - | else if ((Y == g)) |
---|
165 | | - | then [ScriptTransfer(Address(U), ah, unit), ScriptTransfer(Address(fromBase58String(ai)), 1, l), StringEntry("platform_fee", toString(N)), StringEntry((A + "_amount_paid_to_owner"), ag), StringEntry((A + "_nft_transfer_to"), ai), StringEntry((A + "_nft_status"), "REWARDED"), StringEntry((W + "_amount_paid_to_owner"), ag), StringEntry((W + "_nft_transfer_to"), ai), StringEntry((W + "_nft_status"), "REWARDED")] |
---|
166 | | - | else nil |
---|
167 | | - | } |
---|
168 | | - | |
---|
169 | | - | |
---|
170 | | - | |
---|
171 | | - | @Callable(o) |
---|
172 | | - | func cancelAuction (W,Y) = { |
---|
173 | | - | let A = toBase58String(o.transactionId) |
---|
174 | | - | let U = o.caller.bytes |
---|
175 | | - | let aj = getStringValue(this, (W + "_nft_status")) |
---|
176 | | - | let ak = getStringValue(this, (W + "_winner_of_nft")) |
---|
177 | | - | let al = getStringValue(this, (W + "_nft_owner")) |
---|
178 | | - | let O = getStringValue(this, (W + "_nft_on_auction")) |
---|
179 | | - | let am = getStringValue(this, (W + "_highest_bid")) |
---|
180 | | - | if ((ak == "0")) |
---|
181 | | - | then [StringEntry(((A + W) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(al)), 1, fromBase58String(O))] |
---|
182 | | - | else if ((ak != "0")) |
---|
183 | | - | then throw("soory you can't cancel it because already auction placed by someone") |
---|
184 | | - | else nil |
---|
185 | | - | } |
---|
186 | | - | |
---|
187 | | - | |
---|
188 | | - | |
---|
189 | | - | @Callable(o) |
---|
190 | | - | func manualFundTransfer (an,ao) = { |
---|
191 | | - | let U = o.caller.bytes |
---|
192 | | - | let ap = fromBase58String(an) |
---|
193 | | - | let J = o.payments[0].amount |
---|
194 | | - | let aq = ((J / 1000) * 975) |
---|
195 | | - | let N = ((J / 1000) * 25) |
---|
196 | | - | if ((o.payments[0].assetId == unit)) |
---|
197 | | - | then [IntegerEntry((toBase58String(U) + "_transfer"), J), StringEntry("platform_fee", toString(N)), StringEntry((toBase58String(U) + "_transfer_to"), an), ScriptTransfer(Address(ap), aq, unit)] |
---|
198 | | - | else if ((o.payments[0].assetId == f)) |
---|
199 | | - | then [IntegerEntry((toBase58String(U) + "_transfer"), J), StringEntry("platform_fee", toString(N)), StringEntry((toBase58String(U) + "_transfer_to"), an), ScriptTransfer(Address(ap), aq, f)] |
---|
200 | | - | else nil |
---|
| 8 | + | @Callable(c) |
---|
| 9 | + | func transferToken (d,e) = { |
---|
| 10 | + | let f = c.caller.bytes |
---|
| 11 | + | let g = fromBase58String(d) |
---|
| 12 | + | let h = c.payments[0].amount |
---|
| 13 | + | if ((c.payments[0].assetId == a)) |
---|
| 14 | + | then [IntegerEntry((toBase58String(f) + "_transfer"), h), StringEntry((toBase58String(f) + "_transfer_to"), d), ScriptTransfer(Address(g), h, a)] |
---|
| 15 | + | else nil |
---|