tx · 2iWZpHdAzJKqnXiLME5xH6Zf4YxUvkYkfcZNEudNkuEM 3N1SzVmTbEDkLidVVXt6WRX7mDKyDeXivbi: -0.01000000 Waves 2019.07.12 13:39 [582401] smart account 3N1SzVmTbEDkLidVVXt6WRX7mDKyDeXivbi > SELF 0.00000000 Waves
{ "type": 13, "id": "2iWZpHdAzJKqnXiLME5xH6Zf4YxUvkYkfcZNEudNkuEM", "fee": 1000000, "feeAssetId": null, "timestamp": 1562927970237, "version": 1, "sender": "3N1SzVmTbEDkLidVVXt6WRX7mDKyDeXivbi", "senderPublicKey": "3zcHe85aUZ18KVnjH95j2cERsxoAyLnoP7PEZe3NNaaa", "proofs": [ "3Dwz5CSiiLMZR7KzHRyziqUWKWUQBTMEQEByipa1e7K9A4HnSW93ZizWKZbZu7pff3euPGuGcjnsp9Wwi6UayFKE" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAAA1rZXlUb3BCYWxhbmNlAgAAAARfYmlkAAAAAAxrZXlUb3BCaWRkZXICAAAACl90b3BiaWRkZXIAAAAACGtleVRva2VuAgAAAAZfdG9rZW4AAAAADGtleU9yZ2FuaXplcgIAAAAKX29yZ2FuaXplcgAAAAAJa2V5SGVpZ2h0AgAAAAdfaGVpZ2h0AAAAAAppc0ZpbmlzaGVkCQAAZwAAAAIFAAAABmhlaWdodAkBAAAAB2V4dHJhY3QAAAABCQAEGgAAAAIFAAAABHRoaXMFAAAACWtleUhlaWdodAEAAAAKZ2V0QmFsYW5jZQAAAAEAAAAHYWRkcmVzcwQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAAdhZGRyZXNzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADWdldFRvcEJhbGFuY2UAAAAABAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAADWtleVRvcEJhbGFuY2UDCQAAAQAAAAIFAAAA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FkZHJlc3NGcm9tU3RyaW5nAAAAAQUAAAAGYmlkZGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAkAAAIAAAABAgAAACNXcm9uZyBhZGRyZXNzIG9yIG5vdGluZyB0byB0cmFuc2ZlcgkAAAIAAAABAgAAABtBdWN0aW9uIGlzIG5vdCBmaW5pc2hlZCB5ZXQAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABy52jeE=", "chainId": 84, "height": 582401, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let keyTopBalance = "_bid" | |
5 | + | ||
6 | + | let keyTopBidder = "_topbidder" | |
7 | + | ||
8 | + | let keyToken = "_token" | |
9 | + | ||
10 | + | let keyOrganizer = "_organizer" | |
11 | + | ||
12 | + | let keyHeight = "_height" | |
13 | + | ||
14 | + | let isFinished = (height >= extract(getInteger(this, keyHeight))) | |
15 | + | ||
16 | + | func getBalance (address) = match getInteger(this, address) { | |
17 | + | case a: Int => | |
18 | + | a | |
19 | + | case _ => | |
20 | + | 0 | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | func getTopBalance () = match getInteger(this, keyTopBalance) { | |
25 | + | case a: Int => | |
26 | + | a | |
27 | + | case _ => | |
28 | + | 0 | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | @Callable(i) | |
33 | + | func bid () = { | |
34 | + | let bidder = toBase58String(i.caller.bytes) | |
35 | + | let currentBalance = getBalance(bidder) | |
36 | + | if (!(isFinished)) | |
37 | + | then { | |
38 | + | let payment = match i.payment { | |
39 | + | case p: AttachedPayment => | |
40 | + | p | |
41 | + | case _ => | |
42 | + | throw("You have to provide a payment to your bid") | |
43 | + | } | |
44 | + | if ((payment.assetId != unit)) | |
45 | + | then throw("This wallet cannot hold assets other than $Waves") | |
46 | + | else { | |
47 | + | let actualBalance = (currentBalance + payment.amount) | |
48 | + | let topbidderBalance = getTopBalance() | |
49 | + | if ((actualBalance > topbidderBalance)) | |
50 | + | then WriteSet([DataEntry(bidder, actualBalance), DataEntry(keyTopBalance, actualBalance), DataEntry(keyTopBidder, bidder)]) | |
51 | + | else WriteSet([DataEntry(bidder, actualBalance)]) | |
52 | + | } | |
53 | + | } | |
54 | + | else throw("Auction is over") | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | ||
59 | + | @Callable(i) | |
60 | + | func withdraw (address) = { | |
61 | + | let bidder = if ((address == "")) | |
62 | + | then toBase58String(i.caller.bytes) | |
63 | + | else if (if (if (if (if ((address == keyTopBalance)) | |
64 | + | then true | |
65 | + | else (address == keyTopBidder)) | |
66 | + | then true | |
67 | + | else (address == keyToken)) | |
68 | + | then true | |
69 | + | else (address == keyOrganizer)) | |
70 | + | then true | |
71 | + | else (address == keyHeight)) | |
72 | + | then throw("Nice try") | |
73 | + | else address | |
74 | + | let isTopBidder = (getString(this, keyTopBidder) == bidder) | |
75 | + | let isOrganizer = (getString(this, keyOrganizer) == bidder) | |
76 | + | let isBidder = (getBalance(bidder) > 0) | |
77 | + | if (isFinished) | |
78 | + | then if (if (isTopBidder) | |
79 | + | then true | |
80 | + | else isOrganizer) | |
81 | + | then { | |
82 | + | let topBidder = extract(getString(this, keyTopBidder)) | |
83 | + | let Organizer = extract(addressFromString(extract(getString(this, keyOrganizer)))) | |
84 | + | let topBidderAmount = getBalance(topBidder) | |
85 | + | let Token = fromBase58String(extract(getString(this, keyToken))) | |
86 | + | if ((topBidderAmount > 0)) | |
87 | + | then ScriptResult(WriteSet([DataEntry(topBidder, 0)]), TransferSet([ScriptTransfer(extract(addressFromString(topBidder)), 1, Token), ScriptTransfer(Organizer, topBidderAmount, unit)])) | |
88 | + | else throw("Not again") | |
89 | + | } | |
90 | + | else if (isBidder) | |
91 | + | then { | |
92 | + | let amount = getBalance(bidder) | |
93 | + | ScriptResult(WriteSet([DataEntry(bidder, 0)]), TransferSet([ScriptTransfer(extract(addressFromString(bidder)), amount, unit)])) | |
94 | + | } | |
95 | + | else throw("Wrong address or noting to transfer") | |
96 | + | else throw("Auction is not finished yet") | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | @Verifier(tx) | |
101 | + | func verify () = false | |
102 | + |
github/deemru/w8io/026f985 19.38 ms ◑