tx · 5AaqAMzztjiximEhqefsoSE4HtVBxfLRC2DQPqtCaGcJ 3MvqUEAdK8oa1jDS82eqYYVoHTX3S71rRPa: -0.01400000 Waves 2019.09.08 10:00 [666782] smart account 3MvqUEAdK8oa1jDS82eqYYVoHTX3S71rRPa > SELF 0.00000000 Waves
{ "type": 13, "id": "5AaqAMzztjiximEhqefsoSE4HtVBxfLRC2DQPqtCaGcJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1567925876766, "version": 1, "sender": "3MvqUEAdK8oa1jDS82eqYYVoHTX3S71rRPa", "senderPublicKey": "HktRLq8bnL31myXeh7WVXAuMw8Qb7yrhPfMVxucQVeU", "proofs": [ "Y7ftTJbrULuGoiSGX8aNJCeLb4MriYWJ5EsQEzTRim7LukMKsZi9hTuV7FZ2kugy2BYjsyqVxTmqY4KFR9aMbTp" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAgAAAAFpAQAAAAdzZXRob21lAAAAAQAAAAZob21lSWQJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAJYAAAAAQgFAAAAAWkAAAAPY2FsbGVyUHVibGljS2V5BQAAAAZob21lSWQFAAAAA25pbAAAAAFpAQAAAAJleAAAAAIAAAAPc2VsbGVyUHVibGljS2V5AAAABmhvbWVJZAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkCQAAAgAAAAECAAAAFXBheW1lbnQgaXMgb25seSB3YXZlcwQAAAANc2VsbGVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABBQAAAA9zZWxsZXJQdWJsaWNLZXkEAAAAE2J1ZXJQdWJsaWNLZXlCYXNlNTgJAAJYAAAAAQgFAAAAAWkAAAAPY2FsbGVyUHVibGljS2V5BAAAABVzZWxsZXJQdWJsaWNLZXlCYXNlNTgJAAJYAAAAAQUAAAAPc2VsbGVyUHVibGljS2V5BAAAAA9kYXRhRnJvbVN0b3JhZ2UJAAQaAAAAAgUAAAAEdGhpcwUAAAAVc2VsbGVyUHVibGljS2V5QmFzZTU4AwkBAAAACWlzRGVmaW5lZAAAAAEFAAAAD2RhdGFGcm9tU3RvcmFnZQQAAAAIdHJhbnNmZXIJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAANc2VsbGVyQWRkcmVzcwgFAAAAA3BtdAAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAQAAAAFd3JpdGUJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAFXNlbGxlclB1YmxpY0tleUJhc2U1OAAAAAAAAAAAAAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAATYnVlclB1YmxpY0tleUJhc2U1OAUAAAAGaG9tZUlkBQAAAANuaWwJAQAAAAxTY3JpcHRSZXN1bHQAAAACBQAAAAV3cml0ZQUAAAAIdHJhbnNmZXIJAAACAAAAAQIAAAAPc2VsbGVyIGhvbWVsZXNzAAAAAFfegYU=", "chainId": 84, "height": 666782, "spentComplexity": 0 } View: original | compacted Prev: F822a5xKnXH2boAMyQqN67tdpYADWicrvcd9Nec9dfDQ Next: 89d29bm3y3658zeTKz5RaJJUWMXVitVbLDoT8idENdaQ Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func deposit () = { | |
8 | - | let pmt = extract(i.payment) | |
9 | - | if (isDefined(pmt.assetId)) | |
10 | - | then throw("can hodl waves only at the moment") | |
11 | - | else { | |
12 | - | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let currentAmount = match getInteger(this, currentKey) { | |
14 | - | case a: Int => | |
15 | - | a | |
16 | - | case _ => | |
17 | - | 0 | |
18 | - | } | |
19 | - | let newAmount = (currentAmount + pmt.amount) | |
20 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
21 | - | } | |
22 | - | } | |
7 | + | func sethome (homeId) = WriteSet([DataEntry(toBase58String(i.callerPublicKey), homeId)]) | |
23 | 8 | ||
24 | 9 | ||
25 | 10 | ||
26 | 11 | @Callable(i) | |
27 | - | func withdraw (amount) = { | |
28 | - | let currentKey = toBase58String(i.caller.bytes) | |
29 | - | let currentAmount = match getInteger(this, currentKey) { | |
30 | - | case a: Int => | |
31 | - | a | |
32 | - | case _ => | |
33 | - | 0 | |
34 | - | } | |
35 | - | let newAmount = (currentAmount - amount) | |
36 | - | if ((0 > amount)) | |
37 | - | then throw("Can't withdraw negative amount") | |
38 | - | else if ((0 > newAmount)) | |
39 | - | then throw("Not enough balance") | |
40 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
12 | + | func ex (sellerPublicKey,homeId) = { | |
13 | + | let pmt = extract(i.payment) | |
14 | + | if (isDefined(pmt.assetId)) | |
15 | + | then throw("payment is only waves") | |
16 | + | else { | |
17 | + | let sellerAddress = Address(sellerPublicKey) | |
18 | + | let buerPublicKeyBase58 = toBase58String(i.callerPublicKey) | |
19 | + | let sellerPublicKeyBase58 = toBase58String(sellerPublicKey) | |
20 | + | let dataFromStorage = getInteger(this, sellerPublicKeyBase58) | |
21 | + | if (isDefined(dataFromStorage)) | |
22 | + | then { | |
23 | + | let transfer = TransferSet([ScriptTransfer(sellerAddress, pmt.amount, unit)]) | |
24 | + | let write = WriteSet([DataEntry(sellerPublicKeyBase58, 0), DataEntry(buerPublicKeyBase58, homeId)]) | |
25 | + | ScriptResult(write, transfer) | |
26 | + | } | |
27 | + | else throw("seller homeless") | |
28 | + | } | |
41 | 29 | } | |
42 | 30 | ||
43 | 31 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func deposit () = { | |
8 | - | let pmt = extract(i.payment) | |
9 | - | if (isDefined(pmt.assetId)) | |
10 | - | then throw("can hodl waves only at the moment") | |
11 | - | else { | |
12 | - | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let currentAmount = match getInteger(this, currentKey) { | |
14 | - | case a: Int => | |
15 | - | a | |
16 | - | case _ => | |
17 | - | 0 | |
18 | - | } | |
19 | - | let newAmount = (currentAmount + pmt.amount) | |
20 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
21 | - | } | |
22 | - | } | |
7 | + | func sethome (homeId) = WriteSet([DataEntry(toBase58String(i.callerPublicKey), homeId)]) | |
23 | 8 | ||
24 | 9 | ||
25 | 10 | ||
26 | 11 | @Callable(i) | |
27 | - | func withdraw (amount) = { | |
28 | - | let currentKey = toBase58String(i.caller.bytes) | |
29 | - | let currentAmount = match getInteger(this, currentKey) { | |
30 | - | case a: Int => | |
31 | - | a | |
32 | - | case _ => | |
33 | - | 0 | |
34 | - | } | |
35 | - | let newAmount = (currentAmount - amount) | |
36 | - | if ((0 > amount)) | |
37 | - | then throw("Can't withdraw negative amount") | |
38 | - | else if ((0 > newAmount)) | |
39 | - | then throw("Not enough balance") | |
40 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
12 | + | func ex (sellerPublicKey,homeId) = { | |
13 | + | let pmt = extract(i.payment) | |
14 | + | if (isDefined(pmt.assetId)) | |
15 | + | then throw("payment is only waves") | |
16 | + | else { | |
17 | + | let sellerAddress = Address(sellerPublicKey) | |
18 | + | let buerPublicKeyBase58 = toBase58String(i.callerPublicKey) | |
19 | + | let sellerPublicKeyBase58 = toBase58String(sellerPublicKey) | |
20 | + | let dataFromStorage = getInteger(this, sellerPublicKeyBase58) | |
21 | + | if (isDefined(dataFromStorage)) | |
22 | + | then { | |
23 | + | let transfer = TransferSet([ScriptTransfer(sellerAddress, pmt.amount, unit)]) | |
24 | + | let write = WriteSet([DataEntry(sellerPublicKeyBase58, 0), DataEntry(buerPublicKeyBase58, homeId)]) | |
25 | + | ScriptResult(write, transfer) | |
26 | + | } | |
27 | + | else throw("seller homeless") | |
28 | + | } | |
41 | 29 | } | |
42 | 30 | ||
43 | 31 |
github/deemru/w8io/169f3d6 35.54 ms ◑