tx · 38c6RNuLWNQmUAjTzA28tYath6rouwzwpDQLJ6DUefw1 3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa: -0.01500000 Waves 2019.12.21 15:07 [818690] smart account 3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa > SELF 0.00000000 Waves
{ "type": 13, "id": "38c6RNuLWNQmUAjTzA28tYath6rouwzwpDQLJ6DUefw1", "fee": 1500000, "feeAssetId": null, "timestamp": 1576929837340, "version": 1, "sender": "3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa", "senderPublicKey": "5wpzgifs7AQAB2xctYK9m7gDenQv4yCCiLcTgKQTcz9Z", "proofs": [ "uXQvHm7vTsEPEmuAdtAfwb7wL1PDsXLBcjHGMNyVRJhuokxnadaYc6nCU9Uib7FW8F14vestr2n4xhnMEopFa8n" ], "script": "base64:AAIDAAAAAAAAABwIARIDCgEIEgQKAgEBEgMKAQgSAwoBCBIDCgEIAAAAAQAAAAAPYXVjdGlvbkR1cmF0aW9uCQAAaAAAAAIAAAAAAAAABaAAAAAAAAAAAAEAAAAFAAAAAWkBAAAADHJlZ2lzdHJhdGlvbgAAAAEAAAAIdXNlck5hbWUJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwUAAAAIdXNlck5hbWUFAAAAA25pbAAAAAFpAQAAAAxiZWdpbkF1Y3Rpb24AAAACAAAACG1pblByaWNlAAAACGR1cmF0aW9uAwkAAGYAAAACBQAAAAhkdXJhdGlvbgUAAAAPYXVjdGlvbkR1cmF0aW9uCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAATU3BlY2lmaWVkIGR1cmF0aW9uKAkAAaQAAAABBQAAAAhkdXJhdGlvbgIAAAAfKSBleGNlZWRzIHRoZSBtYXhpbXVtIGR1cmF0aW9uKAkAAaQAAAABBQAAAA9hdW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MFAAAAEWhpZ2hlc3RCaWRkZXJBZGRyAAAAAAAAAAABBQAAAAhpdGVtQWRkcgUAAAADbmlsAAAAAKOALIY=", "chainId": 84, "height": 818690, "spentComplexity": 0 } View: original | compacted Prev: DG2Z2mZXoJd5kijdah2tNiDVmeXp76vGEyDNbHyhd6K4 Next: D2BuoDWPC5zSLWWyoD7wQEr74rRp2yK93T5VJ9H3bhxT Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let auctionDuration = (1440 * 1) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func registration (userName) = WriteSet([DataEntry(toBase58String(i.caller.bytes), userName)]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
23 | 28 | let callerAddress = toBase58String(i.caller.bytes) | |
24 | 29 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
25 | 30 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | - | let highestBidAmt = | |
31 | + | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
27 | 32 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | 33 | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | 34 | then (value(highestBidder) == callerAddress) | |
51 | 56 | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | 57 | else { | |
53 | 58 | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | - | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, | |
59 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, highestBidAmt, unit)])) | |
55 | 60 | } | |
56 | 61 | } | |
57 | 62 | ||
71 | 76 | if ((callerAddress != value(owner))) | |
72 | 77 | then throw("Access Denied") | |
73 | 78 | else if ((endTime > lastBlock.height)) | |
74 | - | then throw("Auction is | |
79 | + | then throw("Auction is still running") | |
75 | 80 | else if (!(isDefined(highestBidder))) | |
76 | 81 | then if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
77 | 82 | then throw("Item already withdrawn") | |
99 | 104 | else throw("Nobody won this item"))) | |
100 | 105 | then throw("Access Denied") | |
101 | 106 | else if ((endTime > lastBlock.height)) | |
102 | - | then throw("Auction is | |
107 | + | then throw("Auction is still running") | |
103 | 108 | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
104 | 109 | then throw("The item already transfered") | |
105 | 110 | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let auctionDuration = (1440 * 1) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func registration (userName) = WriteSet([DataEntry(toBase58String(i.caller.bytes), userName)]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | 13 | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | 14 | else { | |
10 | 15 | let auctionId = toBase58String(i.transactionId) | |
11 | 16 | let endTime = (lastBlock.height + duration) | |
12 | 17 | let pmt = extract(i.payment) | |
13 | 18 | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | 19 | then toBase58String(value(pmt.assetId)) | |
15 | 20 | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | 21 | } | |
17 | 22 | ||
18 | 23 | ||
19 | 24 | ||
20 | 25 | @Callable(i) | |
21 | 26 | func bid (auctionId) = { | |
22 | 27 | let pmt = extract(i.payment) | |
23 | 28 | let callerAddress = toBase58String(i.caller.bytes) | |
24 | 29 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
25 | 30 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | - | let highestBidAmt = | |
31 | + | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
27 | 32 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | 33 | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | 34 | then (value(highestBidder) == callerAddress) | |
30 | 35 | else false | |
31 | 36 | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
32 | 37 | then value(highestBidAmt) | |
33 | 38 | else 0)) | |
34 | 39 | if (!(isDefined(getString(this, auctionId)))) | |
35 | 40 | then throw("Auction Id not found") | |
36 | 41 | else if ((lastBlock.height >= endTime)) | |
37 | 42 | then throw("Auction Completed") | |
38 | 43 | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | 44 | then (minPrice >= totalBidAmount) | |
40 | 45 | else false) | |
41 | 46 | then true | |
42 | 47 | else if (isDefined(highestBidAmt)) | |
43 | 48 | then (value(highestBidAmt) >= totalBidAmount) | |
44 | 49 | else false) | |
45 | 50 | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | 51 | then toString(minPrice) | |
47 | 52 | else toString(value(highestBidAmt))))) | |
48 | 53 | else if (!(isDefined(highestBidder))) | |
49 | 54 | then WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
50 | 55 | else if (bidFromTheSameUser) | |
51 | 56 | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | 57 | else { | |
53 | 58 | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | - | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, | |
59 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, highestBidAmt, unit)])) | |
55 | 60 | } | |
56 | 61 | } | |
57 | 62 | ||
58 | 63 | ||
59 | 64 | ||
60 | 65 | @Callable(i) | |
61 | 66 | func ownerWithdraw (auctionId) = { | |
62 | 67 | let callerAddress = toBase58String(i.caller.bytes) | |
63 | 68 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
64 | 69 | let owner = getStringValue(this, (auctionId + "_owner")) | |
65 | 70 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
66 | 71 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
67 | 72 | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
68 | 73 | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
69 | 74 | let ownerAddr = addressFromStringValue(value(owner)) | |
70 | 75 | let itemAddr = fromBase58String(value(itemId)) | |
71 | 76 | if ((callerAddress != value(owner))) | |
72 | 77 | then throw("Access Denied") | |
73 | 78 | else if ((endTime > lastBlock.height)) | |
74 | - | then throw("Auction is | |
79 | + | then throw("Auction is still running") | |
75 | 80 | else if (!(isDefined(highestBidder))) | |
76 | 81 | then if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
77 | 82 | then throw("Item already withdrawn") | |
78 | 83 | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, itemAddr)])) | |
79 | 84 | else if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
80 | 85 | then throw("The bid amount is already transfered") | |
81 | 86 | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, ((highestBidAmt / 100) * 95), unit)])) | |
82 | 87 | } | |
83 | 88 | ||
84 | 89 | ||
85 | 90 | ||
86 | 91 | @Callable(i) | |
87 | 92 | func winnerWithdraw (auctionId) = { | |
88 | 93 | let callerAddress = toBase58String(i.caller.bytes) | |
89 | 94 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
90 | 95 | let owner = getStringValue(this, (auctionId + "_owner")) | |
91 | 96 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
92 | 97 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
93 | 98 | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
94 | 99 | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
95 | 100 | let ownerAddr = addressFromStringValue(value(owner)) | |
96 | 101 | let itemAddr = fromBase58String(value(itemId)) | |
97 | 102 | if ((callerAddress != if (isDefined(highestBidder)) | |
98 | 103 | then value(highestBidder) | |
99 | 104 | else throw("Nobody won this item"))) | |
100 | 105 | then throw("Access Denied") | |
101 | 106 | else if ((endTime > lastBlock.height)) | |
102 | - | then throw("Auction is | |
107 | + | then throw("Auction is still running") | |
103 | 108 | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
104 | 109 | then throw("The item already transfered") | |
105 | 110 | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) | |
106 | 111 | } | |
107 | 112 | ||
108 | 113 |
github/deemru/w8io/169f3d6 35.47 ms ◑