tx · AgKKfnEeXYjAaihuke9gRtrYUosRzBbnuL3dS1ZxWjpL

3MwnT11gaYsujkGzyqjCcmSiM9PBLMgNhv5:  -0.01000000 Waves

2019.09.04 10:50 [660966] smart account 3MwnT11gaYsujkGzyqjCcmSiM9PBLMgNhv5 > SELF 0.00000000 Waves

{ "type": 13, "id": "AgKKfnEeXYjAaihuke9gRtrYUosRzBbnuL3dS1ZxWjpL", "fee": 1000000, "feeAssetId": null, "timestamp": 1567583404849, "version": 1, "sender": "3MwnT11gaYsujkGzyqjCcmSiM9PBLMgNhv5", "senderPublicKey": "3jJFistMjd5qokz2VLaD1PynRXBhDKREFZCgBibyKF7C", "proofs": [ "1wPbdVwr2hnrjf5g4HrkRfxo6iiTKMt5P4cQSkvTy1U8YBnox549cvb1nX8VH9nW9QSF29szH4onq6HyFZMJVS2" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAAtvd25lclB1YktleQEAAABBAZkWLznUd6IFdwagshj88MZgqRsgYkLqTh4N0ei+1lZPmw5tnh7y/g/7B+MZN3zq3Mc7iwEydIsASpVTzXihHpgAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmlj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AAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAF0BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAALb3duZXJQdWJLZXkH59kR2A==", "chainId": 84, "height": 660966, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let ownerPubKey = base58'9BNzoBpPncPuyfnnRMbhXipbhWyiYMQSV4NAnZYKM3jJFistMjd5qokz2VLaD1PynRXBhDKREFZCgBibyKF7CS4F'
5+
6+let NONE = "none"
7+
8+func getNumberByKey (key) = {
9+ let num = match getInteger(this, key) {
10+ case a: Int =>
11+ a
12+ case _ =>
13+ 0
14+ }
15+ num
16+ }
17+
18+
19+func getStrByKey (key) = {
20+ let str = match getString(this, key) {
21+ case a: String =>
22+ a
23+ case _ =>
24+ NONE
25+ }
26+ str
27+ }
28+
29+
30+func getKeyItemPrice (item) = (item + "_price")
31+
32+
33+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
34+
35+
36+func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
37+
38+
39+func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
40+
41+
42+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
43+
44+
45+func getKeyItemData (item) = (item + "_data")
46+
47+
48+func getKeyItemSupplier (item) = (item + "_owner")
49+
50+
51+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
52+
53+
54+func getKeyBalanceSupplier (account) = (account + "_balance")
55+
56+
57+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
58+
59+
60+@Callable(i)
61+func addItem (title,price,data) = {
62+ let supplierAddress = toBase58String(i.caller.bytes)
63+ let item = getKeyItem(supplierAddress, title)
64+ if ((0 >= price))
65+ then throw("purchase amount cannot be less than item price")
66+ else if ((getValueItemSupplier(item) != NONE))
67+ then throw("an item is already exist")
68+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
69+ }
70+
71+
72+
73+@Callable(i)
74+func purchase (item) = {
75+ let pmt = extract(i.payment)
76+ if (isDefined(pmt.assetId))
77+ then throw("can use WAVES only at the moment")
78+ else {
79+ let userAddress = toBase58String(i.caller.bytes)
80+ let price = getValueItemPrice(item)
81+ let supplierAddress = getValueItemSupplier(item)
82+ if ((price > pmt.amount))
83+ then throw("purchase amount cannot be less than item price")
84+ else if ((pmt.amount > price))
85+ then throw("purchase amount cannot be higher than item price")
86+ else if ((supplierAddress == NONE))
87+ then throw("supplier does not exist")
88+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
89+ }
90+ }
91+
92+
93+@Verifier(tx)
94+func verify () = match tx {
95+ case d: SetScriptTransaction =>
96+ sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey)
97+ case d: DataTransaction =>
98+ true
99+ case t: TransferTransaction =>
100+ sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey)
101+ case _ =>
102+ false
103+}
104+

github/deemru/w8io/169f3d6 
33.52 ms