tx · kpqeGW1uyKk3fLep7azDVjNFiCcsYPusNhUP2odZXDm 3N1xRtmfYrHPVPazzLPAdzQsbjPCZsuboLu: -0.01000000 Waves 2019.08.13 13:53 [629216] smart account 3N1xRtmfYrHPVPazzLPAdzQsbjPCZsuboLu > SELF 0.00000000 Waves
{ "type": 13, "id": "kpqeGW1uyKk3fLep7azDVjNFiCcsYPusNhUP2odZXDm", "fee": 1000000, "feeAssetId": null, "timestamp": 1565693674858, "version": 1, "sender": "3N1xRtmfYrHPVPazzLPAdzQsbjPCZsuboLu", "senderPublicKey": "ASGW7oENSusnjTTJ7YUgnfWgvz4DxRLWjWWcn7nVhaV5", "proofs": [ "4djbB4Wmc5gn2N7vjMMRrA6Wc5jp8JUN8DAHhYkaQLxTT45rpv5Y7ta9nU3v3EQQ7JtwGipS1TPhr7vJRybCMrmQ" ], "script": "base64:AAIDAAAAAAAAAAAAAAABAAAAAAx3YXZlc0Fzc2V0SWQBAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAFpAQAAAARzZWxsAAAAAgAAAAVwcmljZQAAAApwcmljZUFzc2V0BAAAAAFwCQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQAAAAAAAAIIBQAAAAFwAAAAB2Fzc2V0SWQFAAAABHVuaXQJAAACAAAAAQIAAAAVWW91IGNhbid0IHNlbGwgV2F2ZXMuAwkAAGcAAAACAAAAAAAAAAAACAUAAAABcAAAAAZhbW91bnQJAAACAAAAAQIAAAASWW91IGNhbid0IG5vdGhpbmcuCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQACWAAAAAEIBQAAAAFpAAAADXRyYW5zYWN0aW9uSWQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAZoAAAABBQAAAAVwcmljZQkAAZoAAAABCAUAAAABcAAAAAZhbW91bnQFAAAACnByaWNlQXNzZXQ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Fuc2ZlcgAAAAMJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAABnNlbGxlcgUAAAAFcHJpY2UFAAAACnByaWNlQXNzZXQFAAAAA25pbAAAAADnL9an", "chainId": 84, "height": 629216, "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 wavesAssetId = base58'11111111111111111111111111111111' | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func sell (price,priceAsset) = { | |
8 | + | let p = extract(i.payment) | |
9 | + | if ((p.assetId == unit)) | |
10 | + | then throw("You can't sell Waves.") | |
11 | + | else if ((0 >= p.amount)) | |
12 | + | then throw("You can't nothing.") | |
13 | + | else WriteSet([DataEntry(toBase58String(i.transactionId), ((((toBytes(price) + toBytes(p.amount)) + priceAsset) + extract(extract(i.payment).assetId)) + i.callerPublicKey))]) | |
14 | + | } | |
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | @Callable(i) | |
19 | + | func cancel (id) = { | |
20 | + | let data = extract(getBinary(this, id)) | |
21 | + | let price = toInt(take(data, 8)) | |
22 | + | let amount = toInt(take(drop(data, 0), 8)) | |
23 | + | let priceAsset = take(drop(data, (8 + 8)), 32) | |
24 | + | let amountAsset = take(drop(data, ((8 + 8) + 32)), 32) | |
25 | + | let seller = drop(data, (((8 + 8) + 32) + 32)) | |
26 | + | if ((seller != i.callerPublicKey)) | |
27 | + | then throw("Invalid user.") | |
28 | + | else ScriptResult(WriteSet([DataEntry(id, ((((toBytes(price) + toBytes(0)) + priceAsset) + amountAsset) + seller))]), TransferSet([ScriptTransfer(addressFromPublicKey(seller), amount, amountAsset)])) | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | ||
33 | + | @Callable(i) | |
34 | + | func buy (id) = { | |
35 | + | let data = extract(getBinary(this, id)) | |
36 | + | let price = toInt(take(data, 8)) | |
37 | + | let amount = toInt(take(drop(data, 0), 8)) | |
38 | + | let priceAsset = take(drop(data, (8 + 8)), 32) | |
39 | + | let amountAsset = take(drop(data, ((8 + 8) + 32)), 32) | |
40 | + | let seller = drop(data, (((8 + 8) + 32) + 32)) | |
41 | + | let p = extract(i.payment) | |
42 | + | let amountToBuy = (p.amount / price) | |
43 | + | if ((p.assetId == wavesAssetId)) | |
44 | + | then throw("Invalid payment asset.") | |
45 | + | else if ((0 >= amountToBuy)) | |
46 | + | then throw("Invalid payment amount.") | |
47 | + | else if (((amountToBuy * price) != p.amount)) | |
48 | + | then throw("Invalid payment amount.") | |
49 | + | else if ((size(data) != ((((8 + 8) + 32) + 32) + 32))) | |
50 | + | then throw("Already sold or cancelled.") | |
51 | + | else if ((amountToBuy > amount)) | |
52 | + | then throw("Not enough items in stock.") | |
53 | + | else if (if ((priceAsset != p.assetId)) | |
54 | + | then true | |
55 | + | else !(if ((priceAsset == wavesAssetId)) | |
56 | + | then (p.assetId == unit) | |
57 | + | else false)) | |
58 | + | then throw("Invalid payment asset.") | |
59 | + | else ScriptResult(WriteSet([DataEntry(id, ((((toBytes(price) + toBytes((amount - amountToBuy))) + priceAsset) + amountAsset) + seller))]), TransferSet([ScriptTransfer(i.caller, amountToBuy, amountAsset), ScriptTransfer(addressFromPublicKey(seller), price, priceAsset)])) | |
60 | + | } | |
61 | + | ||
62 | + |
github/deemru/w8io/026f985 27.48 ms ◑