tx · 2Wwify76SyDEeG8fgXADobWBm3QiZpTbQVph3C9t1Kfq

3Mx6Fhgx2b7Vrcg5cPwmcGx2UTrCsGy16hX:  -0.05000000 Waves

2019.08.21 13:55 [640788] smart account 3Mx6Fhgx2b7Vrcg5cPwmcGx2UTrCsGy16hX > SELF 0.00000000 Waves

{ "type": 13, "id": "2Wwify76SyDEeG8fgXADobWBm3QiZpTbQVph3C9t1Kfq", "fee": 5000000, "feeAssetId": null, "timestamp": 1566384885090, "version": 1, "sender": "3Mx6Fhgx2b7Vrcg5cPwmcGx2UTrCsGy16hX", "senderPublicKey": "rbQBcP925Nu3mB58D4Zw36LLDks2LgrcbshyaiSJSHy", "proofs": [ "5uwLPzDxSTzrPyE718YHEEjiT8quJekY4SgHMHQh1roX64hfgPcgwKyH5NoJgU1zSXF591xm13pZ3z8bZhT2z9Af" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFuBQAAAAckbWF0Y2gwBQAAAAFuAAAAAAAAAAAAAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzBQAAAAROT05FAQAAAApnZXRLZXlJdGVtAAAAAgAAAAhzdXBwbGllcgAAAAV0aXRsZQkAASwAAAACAgAAAAVpdGVtXwkAAlgAAAABCQAB9wAAAAEJAAGbAAAAAQkAASwAAAACBQAAAAhzdXBwbGllcgUAAAAFdGl0bGUBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAg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wbGllckFkZHJlc3MDCQAAZwAAAAIAAAAAAAAAAAAFAAAAB2JhbGFuY2UJAAACAAAAAQIAAAAUaW5zdWZmaWNpZW50IGJhbGFuY2UJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAVZ2V0S2V5QmFsYW5jZVN1cHBsaWVyAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzAAAAAAAAAAAABQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAA9zdXBwbGllckFkZHJlc3MJAQAAABdnZXRWYWx1ZUJhbGFuY2VTdXBwbGllcgAAAAEFAAAAD3N1cHBsaWVyQWRkcmVzcwUAAAAEdW5pdAUAAAADbmlsAAAAAMikgYk=", "chainId": 84, "height": 640788, "spentComplexity": 0 } View: original | compacted Prev: C4Y9dZCGzspCU3mkj5WL2GPupYGkTG6ggYAZU6aT3h4k Next: BDpFoTbsQqGXSdNdUDrDPAvhKWzr6YCYJbJt13pZS5qX Diff:
OldNewDifferences
8282 }
8383
8484
85+
86+@Callable(i)
87+func withdraw () = {
88+ let supplierAddress = toBase58String(i.caller.bytes)
89+ let balance = getValueBalanceSupplier(supplierAddress)
90+ if ((0 >= balance))
91+ then throw("insufficient balance")
92+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), getValueBalanceSupplier(supplierAddress), unit)]))
93+ }
94+
95+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getNumberByKey (key) = match getInteger(this, key) {
77 case n: Int =>
88 n
99 case _ =>
1010 0
1111 }
1212
1313
1414 func getStrByKey (key) = match getString(this, key) {
1515 case s: String =>
1616 s
1717 case _ =>
1818 NONE
1919 }
2020
2121
2222 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
2323
2424
2525 func getKeyItemSupplier (item) = (item + "_owner")
2626
2727
2828 func getKeyItemPrice (item) = (item + "_price")
2929
3030
3131 func getKeyItemData (item) = (item + "_data")
3232
3333
3434 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3535
3636
3737 func getKeyBalanceSupplier (account) = (account + "_account")
3838
3939
4040 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4141
4242
4343 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4444
4545
4646 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
4747
4848
4949 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5050
5151
5252 @Callable(i)
5353 func addItem (title,price,data) = {
5454 let supplierAddress = toBase58String(i.caller.bytes)
5555 let item = getKeyItem(supplierAddress, title)
5656 if ((0 >= price))
5757 then throw("purchase amount cannot be ess than item price")
5858 else if ((getValueItemSupplier(item) != NONE))
5959 then throw("an item already exists")
6060 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
6161 }
6262
6363
6464
6565 @Callable(i)
6666 func purchase (item) = {
6767 let payment = extract(i.payment)
6868 if (isDefined(payment.assetId))
6969 then throw("can use only WAVES token at the moment")
7070 else {
7171 let userAddress = toBase58String(i.caller.bytes)
7272 let price = getValueItemPrice(item)
7373 let supplierAddress = getValueItemSupplier(item)
7474 if ((price > payment.amount))
7575 then throw("purchase price cannot be lower than item price")
7676 else if ((price > payment.amount))
7777 then throw("purchase price cannot be higher than item price")
7878 else if ((supplierAddress == NONE))
7979 then throw("supplier does not exist")
8080 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + payment.amount))])
8181 }
8282 }
8383
8484
85+
86+@Callable(i)
87+func withdraw () = {
88+ let supplierAddress = toBase58String(i.caller.bytes)
89+ let balance = getValueBalanceSupplier(supplierAddress)
90+ if ((0 >= balance))
91+ then throw("insufficient balance")
92+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), getValueBalanceSupplier(supplierAddress), unit)]))
93+ }
94+
95+

github/deemru/w8io/169f3d6 
27.80 ms