tx · 6v14sEeZbwiDovgQmERb4vpDQNSXN31MNxCUpJQAqvV7

3N4GTCukDjYonQt6FBuw7zxTbs8FoEB9LVv:  -0.01000000 Waves

2019.07.29 18:48 [607578] smart account 3N4GTCukDjYonQt6FBuw7zxTbs8FoEB9LVv > SELF 0.00000000 Waves

{ "type": 13, "id": "6v14sEeZbwiDovgQmERb4vpDQNSXN31MNxCUpJQAqvV7", "fee": 1000000, "feeAssetId": null, "timestamp": 1564415289177, "version": 1, "sender": "3N4GTCukDjYonQt6FBuw7zxTbs8FoEB9LVv", "senderPublicKey": "FmMaLSMSskjeGMqLLcEkC6t5Xn8TeNwTSfmETe3jwnoC", "proofs": [ "5x9Ln9E1BWC1795jDPZQFkLovX7JG5L6UkxNVfFuZM9nL3tjRT3n9FvGUmYCctATckkbT61MPPGg8BCTJE1ySnW2" ], "script": "base64:AAIDAAAAAAAAAAAAAAAaAAAAAAptaW5WYXJpYW50AAAAAAAAAAABAAAAAAptYXhWYXJpYW50AAAAAAAAAAAkAAAAAAlzdG9wQmxvY2sAAAAAAAAKy/YAAAAAD2tPd25lckNvbWlzc2lvbgAAAAAAAAAABQAAAAASa1BsYXRmb3JtQ29taXNzaW9uAAAAAAAAAAAFAAAAAAprQ29taXNzaW9uCQAAZAAAAAIFAAAAD2tPd25lckNvbWlzc2lvbgUAAAASa1BsYXRmb3JtQ29taXNzaW9uAAAAABF3aW5uaW5nVmFyaWFudEtleQIAAAAHd2luX3ZhcgAAAAAQdG90YWxQYXltZW50c0tleQIAAAAOdG90YWxfcGF5bWVudHMAAAAADXBhaWRLZXlQcmVmaXgCAAAABXBhaWRfAAAAAAliaWRQcmVmaXgCAAAABGJpZF8AAAAAE2JpZFBheW1lbnRLZXlQcmVmaXgCAAAADGJpZF9wYXltZW50XwAAAAAZdG90YWxWYXJpYW50Qmlkc0tleVByZWZpeAIAAAAPdG90YWxfdmFyX2JpZHNfAQAAAA12ZXJpZnlEZWZhdWx0AAAAAQAAAAF0CQAB9AAAAAM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AkAAaQAAAABBQAAAA53aW5uaW5nVmFyaWFudAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAApnZXRQYWlkS2V5AAAAAQUAAAANY2FsbGVyQWRkcmVzcwYJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEXdpbm5pbmdWYXJpYW50S2V5BQAAAA53aW5uaW5nVmFyaWFudAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAANjdHgAAAAGY2FsbGVyBQAAAAdyZXZlbnVlBQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAA7U3RvcCBibG9jayBoYWQgbm90IGJlZW4gcmVhY2hlZCBvciB0aGUgY2FsbGVyIGhhZCBiZWVuIHBhaWQAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBgkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDAJAQAAAA12ZXJpZnlEZWZhdWx0AAAAAQUAAAABdAkAAAIAAAABAgAAABpVbmhhbmRsZWQgdHJhbnNhY3Rpb24gdHlwZZlXWG8=", "chainId": 84, "height": 607578, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let minVariant = 1
5+
6+let maxVariant = 36
7+
8+let stopBlock = 707574
9+
10+let kOwnerComission = 5
11+
12+let kPlatformComission = 5
13+
14+let kComission = (kOwnerComission + kPlatformComission)
15+
16+let winningVariantKey = "win_var"
17+
18+let totalPaymentsKey = "total_payments"
19+
20+let paidKeyPrefix = "paid_"
21+
22+let bidPrefix = "bid_"
23+
24+let bidPaymentKeyPrefix = "bid_payment_"
25+
26+let totalVariantBidsKeyPrefix = "total_var_bids_"
27+
28+func verifyDefault (t) = sigVerify(t.bodyBytes, t.proofs[0], t.senderPublicKey)
29+
30+
31+func getTotalPayments () = match getInteger(this, totalPaymentsKey) {
32+ case n: Int =>
33+ n
34+ case _ =>
35+ 0
36+}
37+
38+
39+func getPaymentAmount (ctx) = match ctx.payment {
40+ case p: AttachedPayment =>
41+ match p.assetId {
42+ case assetId: ByteVector =>
43+ throw("Only WAVES asset is accepted")
44+ case _ =>
45+ if ((p.amount != 0))
46+ then p.amount
47+ else throw("Payment amount must be non-zero")
48+ }
49+ case _ =>
50+ throw("Payment must be attached")
51+}
52+
53+
54+func getBidKey (address,variant) = {
55+ let bidKeyPrefix = (bidPrefix + address)
56+ (bidKeyPrefix + toString(variant))
57+ }
58+
59+
60+func getBid (address,variant) = match getInteger(this, getBidKey(address, variant)) {
61+ case n: Int =>
62+ n
63+ case _ =>
64+ 0
65+}
66+
67+
68+func getTotalVariantBidsKey (variant) = (totalVariantBidsKeyPrefix + toString(variant))
69+
70+
71+func getTotalVariantBids (variant) = match getInteger(this, getTotalVariantBidsKey(variant)) {
72+ case n: Int =>
73+ n
74+ case _ =>
75+ 0
76+}
77+
78+
79+func mapIntRange (value,srcMin,srcMax,dstMin,dstMax) = ((((value - srcMin) * (dstMax - dstMin)) / (srcMax - srcMin)) + dstMin)
80+
81+
82+func randVariant (ctx) = {
83+ let lastBlockHash = sha256(lastBlock.generationSignature)
84+ let randSeed = toInt((fromBase16String("000000000000") + takeRightBytes(lastBlockHash, 2)))
85+ mapIntRange(randSeed, 0, 65535, minVariant, maxVariant)
86+ }
87+
88+
89+func getWinningVariant (ctx) = match getInteger(this, winningVariantKey) {
90+ case n: Int =>
91+ n
92+ case _ =>
93+ randVariant(ctx)
94+}
95+
96+
97+func getCallerAddress (ctx) = toBase58String(addressFromPublicKey(ctx.callerPublicKey).bytes)
98+
99+
100+func getPaidKey (address) = (paidKeyPrefix + address)
101+
102+
103+func hasBeenPaid (address) = match getBoolean(this, getPaidKey(address)) {
104+ case b: Boolean =>
105+ b
106+ case _ =>
107+ false
108+}
109+
110+
111+func assertHasNotBeenPaid (address) = if (hasBeenPaid(address))
112+ then throw("The caller has already been paid")
113+ else true
114+
115+
116+@Callable(ctx)
117+func randVar () = WriteSet([DataEntry("randVar", randVariant(ctx))])
118+
119+
120+
121+@Callable(ctx)
122+func setBid (variant) = if ((ctx.caller == this))
123+ then throw("Script owner is not allowed to bid")
124+ else if (if ((variant > maxVariant))
125+ then true
126+ else (minVariant > variant))
127+ then throw("Variant is out of range")
128+ else {
129+ let callerAddress = getCallerAddress(ctx)
130+ let bidPaymentAmount = getPaymentAmount(ctx)
131+ if ((height >= stopBlock))
132+ then throw((("Stop block " + toString(stopBlock)) + " reached"))
133+ else WriteSet([DataEntry(getTotalVariantBidsKey(variant), (getTotalVariantBids(variant) + bidPaymentAmount)), DataEntry(getBidKey(callerAddress, variant), (getBid(callerAddress, variant) + bidPaymentAmount)), DataEntry(totalPaymentsKey, (getTotalPayments() + bidPaymentAmount))])
134+ }
135+
136+
137+
138+@Callable(ctx)
139+func resetPaid () = {
140+ let callerAddress = getCallerAddress(ctx)
141+ WriteSet([DataEntry(getPaidKey(callerAddress), false)])
142+ }
143+
144+
145+
146+@Callable(ctx)
147+func payWinner () = {
148+ let callerAddress = getCallerAddress(ctx)
149+ if (if ((height >= stopBlock))
150+ then assertHasNotBeenPaid(callerAddress)
151+ else false)
152+ then {
153+ let winningVariant = getWinningVariant(ctx)
154+ let totalWinningVariantBids = getTotalVariantBids(winningVariant)
155+ let revenue = if ((totalWinningVariantBids > 0))
156+ then fraction((getTotalPayments() * getBid(callerAddress, winningVariant)), kComission, (100 * totalWinningVariantBids))
157+ else 0
158+ if ((0 >= revenue))
159+ then throw(("The caller has no bids for the variant " + toString(winningVariant)))
160+ else ScriptResult(WriteSet([DataEntry(getPaidKey(callerAddress), true), DataEntry(winningVariantKey, winningVariant)]), TransferSet([ScriptTransfer(ctx.caller, revenue, unit)]))
161+ }
162+ else throw("Stop block had not been reached or the caller had been paid")
163+ }
164+
165+
166+@Verifier(tx)
167+func verify () = match tx {
168+ case t: TransferTransaction|SetScriptTransaction|InvokeScriptTransaction|DataTransaction =>
169+ verifyDefault(t)
170+ case _ =>
171+ throw("Unhandled transaction type")
172+}
173+

github/deemru/w8io/026f985 
17.39 ms