tx · 6W2C7G9daoitaLD8HwceYiDbNR5Buq5cLePCPAwoYHK6 3N5eaZXgSm4N46udxgJmXZVLwaqMvFrRgCy: -0.01500000 Waves 2019.12.14 07:50 [808088] smart account 3N5eaZXgSm4N46udxgJmXZVLwaqMvFrRgCy > SELF 0.00000000 Waves
{ "type": 13, "id": "6W2C7G9daoitaLD8HwceYiDbNR5Buq5cLePCPAwoYHK6", "fee": 1500000, "feeAssetId": null, "timestamp": 1576299013725, "version": 1, "sender": "3N5eaZXgSm4N46udxgJmXZVLwaqMvFrRgCy", "senderPublicKey": "AC4GJMwFZ7vNCSXZjLu7LxTo71o6UMCZyk9NqwQ9YU7T", "proofs": [ "5pmYDFuzx61vvTPQLDGkwGKKnoj4YPEh1S22ZNkaCM9mmti1L41tsXFjv4rhyE28tFFYy3pwiHYs4MGq3mdXvD6A" ], "script": "base64:AAIDAAAAAAAAABIIARIECgIBARIDCgEIEgMKAQgAAAABAAAAAA9hdWN0aW9uRHVyYXRpb24JAABoAAAAAgAAAAAAAAAFoAAAAAAAAAAAAQAAAAMAAAABaQEAAAAMYmVnaW5BdWN0aW9uAAAAAgAAAAhtaW5QcmljZQAAAAhkdXJhdGlvbgMJAABmAAAAAgUAAAAIZHVyYXRpb24FAAAAD2F1Y3Rpb25EdXJhdGlvbgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAE1NwZWNpZmllZCBkdXJhdGlvbigJAAGkAAAAAQUAAAAIZHVyYXRpb24CAAAAHykgZXhjZWVkcyB0aGUgbWF4aW11bSBkdXJhdGlvbigJAAGkAAAAAQUAAAAPYXVjdGlvbkR1cmF0aW9uAgAAAAEpBAAAAAlhdWN0aW9uSWQJAAJYAAAAAQgFAAAAAWkAAAANdHJhbnNhY3Rpb25JZAQAAAAHZW5kVGltZQkAAGQAAAACCAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAUAAAAIZHVyYXRpb24EAAAAA3BtdAkBAAAAB2V4dHJhY3Q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QEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAACWF1Y3Rpb25JZAIAAAAHX3N0YXR1cwYFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAABFoaWdoZXN0QmlkZGVyQWRkcgAAAAAAAAAAAQEAAAAGVB9aghjxCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAACW93bmVyQWRkcgUAAAANaGlnaGVzdEJpZEFtdAUAAAAEdW5pdAUAAAADbmlsAAAAANVLghk=", "chainId": 84, "height": 808088, "spentComplexity": 0 } View: original | compacted Prev: none Next: 8ADMhi57eTzJK7JZQe1f1npq8Fwt2mX6ei5rkLNP2dW2 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let auctionDuration = (1440 * 1) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | + | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | + | else { | |
10 | + | let auctionId = toBase58String(i.transactionId) | |
11 | + | let endTime = (lastBlock.height + duration) | |
12 | + | let pmt = extract(i.payment) | |
13 | + | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | + | } | |
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | @Callable(i) | |
21 | + | func bid (auctionId) = { | |
22 | + | let pmt = extract(i.payment) | |
23 | + | let callerAddress = toBase58String(i.caller.bytes) | |
24 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
25 | + | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | + | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
27 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | + | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | + | then (value(highestBidder) == callerAddress) | |
30 | + | else false | |
31 | + | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
32 | + | then value(highestBidAmt) | |
33 | + | else 0)) | |
34 | + | if (!(isDefined(getIntegerValue(this, auctionId)))) | |
35 | + | then throw("Auction Id not found") | |
36 | + | else if ((lastBlock.height >= endTime)) | |
37 | + | then throw("Auction Completed") | |
38 | + | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | + | then (minPrice >= totalBidAmount) | |
40 | + | else false) | |
41 | + | then true | |
42 | + | else if (isDefined(highestBidAmt)) | |
43 | + | then (value(highestBidAmt) >= totalBidAmount) | |
44 | + | else false) | |
45 | + | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | + | then toString(minPrice) | |
47 | + | else toString(value(highestBidAmt))))) | |
48 | + | else if (!(isDefined(highestBidder))) | |
49 | + | then WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
50 | + | else if (bidFromTheSameUser) | |
51 | + | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | + | else { | |
53 | + | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, value(highestBidAmt), unit)])) | |
55 | + | } | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func withdraw (auctionId) = { | |
62 | + | let pmt = extract(i.payment) | |
63 | + | let callerAddress = toBase58String(i.caller.bytes) | |
64 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
65 | + | let owner = getStringValue(this, (auctionId + "_owner")) | |
66 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
67 | + | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
68 | + | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
69 | + | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
70 | + | let ownerAddr = addressFromStringValue(value(owner)) | |
71 | + | let itemAddr = addressFromStringValue(value(itemId)) | |
72 | + | if ((endTime > lastBlock.height)) | |
73 | + | then throw("Auction is not finished yet") | |
74 | + | else if (!(isDefined(highestBidder))) | |
75 | + | then if (!(isDefined(getBoolean(this, (auctionId + "_status"))))) | |
76 | + | then throw("Owner already withdrawn the item") | |
77 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, base58'itemAddr')])) | |
78 | + | else if (isDefined(getBoolean(this, (auctionId + "_status")))) | |
79 | + | then throw("The item is transfered to the highest bidder and the bid amount is transfered to the owner") | |
80 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, base58'itemAddr'), ScriptTransfer(ownerAddr, highestBidAmt, unit)])) | |
81 | + | } | |
82 | + | ||
83 | + |
github/deemru/w8io/169f3d6 25.21 ms ◑