4 | | - | let a = (1440 * 1) |
---|
5 | | - | |
---|
6 | | - | @Callable(b) |
---|
7 | | - | func beginAuction (c,d) = if ((d > a)) |
---|
8 | | - | then throw((((("Specified duration(" + toString(d)) + ") exceeds the maximum duration(") + toString(a)) + ")")) |
---|
9 | | - | else { |
---|
10 | | - | let e = toBase58String(b.transactionId) |
---|
11 | | - | let f = (lastBlock.height + d) |
---|
12 | | - | let g = extract(b.payment) |
---|
13 | | - | WriteSet([DataEntry(e, e), DataEntry((e + "_endTime"), f), DataEntry((e + "_owner"), toBase58String(b.caller.bytes)), DataEntry((e + "_itemId"), if (isDefined(g.assetId)) |
---|
14 | | - | then toBase58String(value(g.assetId)) |
---|
15 | | - | else throw("Item not atached")), DataEntry((e + "_minPrice"), c)]) |
---|
16 | | - | } |
---|
19 | | - | |
---|
20 | | - | @Callable(b) |
---|
21 | | - | func bid (e) = { |
---|
22 | | - | let h = toBase58String(b.caller.bytes) |
---|
23 | | - | let f = getIntegerValue(this, (e + "_endTime")) |
---|
24 | | - | let c = getIntegerValue(this, (e + "_minPrice")) |
---|
25 | | - | let i = getInteger(this, (e + "_highestBidAmt")) |
---|
26 | | - | let j = getString(this, (e + "_highestBidder")) |
---|
27 | | - | let k = if (isDefined(j)) |
---|
28 | | - | then (value(j) == h) |
---|
29 | | - | else false |
---|
30 | | - | let l = (1000000 + (if (k) |
---|
31 | | - | then value(i) |
---|
32 | | - | else 0)) |
---|
33 | | - | if (!(isDefined(getIntegerValue(this, e)))) |
---|
34 | | - | then throw("Auction Id not found") |
---|
35 | | - | else if ((lastBlock.height >= f)) |
---|
36 | | - | then throw("Auction Completed") |
---|
37 | | - | else if (if (if (!(isDefined(i))) |
---|
38 | | - | then (c >= l) |
---|
39 | | - | else false) |
---|
40 | | - | then true |
---|
41 | | - | else if (isDefined(i)) |
---|
42 | | - | then (value(i) >= l) |
---|
43 | | - | else false) |
---|
44 | | - | then throw(("Bid must be more then " + (if (!(isDefined(i))) |
---|
45 | | - | then toString(c) |
---|
46 | | - | else toString(value(i))))) |
---|
47 | | - | else if (!(isDefined(j))) |
---|
48 | | - | then WriteSet([DataEntry((e + "_highestBidder"), h), DataEntry((e + "_highestBidAmt"), l)]) |
---|
49 | | - | else if (k) |
---|
50 | | - | then WriteSet([DataEntry((e + "_highestBidAmt"), l)]) |
---|
51 | | - | else { |
---|
52 | | - | let m = addressFromStringValue(value(j)) |
---|
53 | | - | ScriptResult(WriteSet([DataEntry((e + "_highestBidder"), h), DataEntry((e + "_highestBidAmt"), l)]), TransferSet([ScriptTransfer(m, value(i), unit)])) |
---|
54 | | - | } |
---|
55 | | - | } |
---|
| 6 | + | @Callable(a) |
---|
| 7 | + | func bid (b) = WriteSet([DataEntry("Content_Variable", "hello")]) |
---|