tx · Dxo7s9WwoxWazPmvudp3fbUHFhqyFETAxzyq473buZBg

3N1d2B1c1yMrabKji95R245LrxRF9ZCAWm6:  -0.01000000 Waves

2019.10.21 11:15 [729578] smart account 3N1d2B1c1yMrabKji95R245LrxRF9ZCAWm6 > SELF 0.00000000 Waves

{ "type": 13, "id": "Dxo7s9WwoxWazPmvudp3fbUHFhqyFETAxzyq473buZBg", "fee": 1000000, "feeAssetId": null, "timestamp": 1571645737844, "version": 1, "sender": "3N1d2B1c1yMrabKji95R245LrxRF9ZCAWm6", "senderPublicKey": "DE5h64UZ9quqybMBa3uZWSR2K668E4J6ZPRikbR3Lff4", "proofs": [ "2pCGfih6HUYV8NqdwTrEm1dcSrUAtuFnhwbn2AnGCkNRspvDCXnMBSrisQD4BrZJ1ZRsjXLN2ro7byCjHNfu2aGU" ], "script": "base64:AAIDAAAAAAAAABAIARIFCgMIAQgSAwoBCBIAAAAADgAAAAAGcHViS2V5AQAAACC1phkS63+p/M0H9U7E7+iDJw5jeZufm/fvgi7ZeZonDwAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAABFnZXRWYWx1ZUl0ZW1Q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AAAF0BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAGcHViS2V5BwSOrQ4=", "chainId": 84, "height": 729578, "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 pubKey = base58'DE5h64UZ9quqybMBa3uZWSR2K668E4J6ZPRikbR3Lff4'
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("payment can be done only by WAVES")
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+
94+@Callable(i)
95+func withdraw () = {
96+ let supplierAddress = toBase58String(i.caller.bytes)
97+ let balance = getValueBalanceSupplier(supplierAddress)
98+ if ((0 >= balance))
99+ then throw("insufficient balance")
100+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
101+ }
102+
103+
104+@Verifier(tx)
105+func verify () = match tx {
106+ case d: DataTransaction =>
107+ sigVerify(tx.bodyBytes, tx.proofs[0], pubKey)
108+ case i: InvokeScriptTransaction =>
109+ sigVerify(tx.bodyBytes, tx.proofs[0], pubKey)
110+ case t: IssueTransaction =>
111+ sigVerify(tx.bodyBytes, tx.proofs[0], pubKey)
112+ case _ =>
113+ false
114+}
115+

github/deemru/w8io/fabc49c 
19.77 ms