tx · 4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL

3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP:  -0.01400000 Waves

2021.11.18 16:43 [1796559] smart account 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP > SELF 0.00000000 Waves

{ "type": 13, "id": "4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL", "fee": 1400000, "feeAssetId": null, "timestamp": 1637243020461, "version": 2, "chainId": 84, "sender": "3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP", "senderPublicKey": "HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq", "proofs": [ "3ZupFP5JJwqGUzuZ5i99W2rpXhbFesRWiK6q2gUsqL1m8e3YRanznxu1yF5hQqZaZBKQhTV4FEqfSYoGPbAEhV7H" ], "script": "base64:AAIDAAAAAAAAABAIARIFCgMIAQgSAwoBCBIAAAAAEQAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIPr6UCy9pj38gKwWFLWxgxjXdgaG+HWNPUCI9qmcr64gAAAAAAtwdWJLZXlBbGljZQEAAAAg+vpQLL2mPfyArBYUtbGDGNd2Bob4dY09QIj2qZyvriAAAAAACXB1YktleUJvYgEAAAAglLAkeqfLsZeQupv/2xfSzDiecKRph4OtJwpInBvH10sAAAAADHB1YktleUNvb3BlcgEAAAAgy+JbV1o7QQIJssPuN7nyhSuLgAWQqXd2UgJecSzNQUgAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABdAUAAAAHJG1hdGNoMAUAAAABdAAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAA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2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGCQAAZwAAAAIJAABkAAAAAgkAAGQAAAACBQAAAAtzaWduZWRBbGljZQUAAAAJc2lnbmVkQm9iBQAAAAxzaWduZWRDb29wZXIAAAAAAAAAAAK/dU+T", "height": 1796559, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9184FjYaMmmKUVzh2434rMhdi5DdN4GNUv3dzTYYCa27 Next: 8RERozAWNashVZxfUPsJ17kmpiRKb4Hg9VJWgHC4tijv Diff:
OldNewDifferences
9898 }
9999
100100
101+
102+@Callable(i)
103+func withdraw () = {
104+ let supplierAddress = toBase58String(i.caller.bytes)
105+ let balance = getValueBalanceSupplier(supplierAddress)
106+ if ((0 >= balance))
107+ then throw("no money - no honey")
108+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
109+ }
110+
111+
101112 @Verifier(tx)
102113 func verify () = {
103114 let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ownerPublicKey = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq'
55
66 let pubKeyAlice = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq'
77
88 let pubKeyBob = base58'B1R7zeh6VgTv4Xxe3aHhdoZ9aQgWcqN8LFC9smacE96r'
99
1010 let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o'
1111
1212 let NONE = "none"
1313
1414 func getNumberByKey (key) = {
1515 let num = match getInteger(this, key) {
1616 case t: Int =>
1717 t
1818 case _ =>
1919 0
2020 }
2121 num
2222 }
2323
2424
2525 func getStrByKey (key) = {
2626 let str = match getString(this, key) {
2727 case t: String =>
2828 t
2929 case _ =>
3030 NONE
3131 }
3232 str
3333 }
3434
3535
3636 func getKeyItemPrice (item) = (item + "_price")
3737
3838
3939 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4040
4141
4242 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4343
4444
4545 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4646
4747
4848 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4949
5050
5151 func getKeyItemData (item) = (item + "_data")
5252
5353
5454 func getKeyItemSupplier (item) = (item + "_owner")
5555
5656
5757 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5858
5959
6060 func getKeyBalanceSupplier (account) = (account + "_balance")
6161
6262
6363 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6464
6565
6666 @Callable(i)
6767 func addItem (title,price,data) = {
6868 let supplierAddress = toBase58String(i.caller.bytes)
6969 let item = getKeyItem(supplierAddress, title)
7070 if ((0 >= price))
7171 then throw("purchase amount cannot be less than item price")
7272 else if ((getValueItemSupplier(item) != NONE))
7373 then throw("an item is already exist")
7474 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
7575 }
7676
7777
7878
7979 @Callable(i)
8080 func purchase (itemKey) = {
8181 let pmt = extract(i.payment)
8282 if (isDefined(pmt.assetId))
8383 then throw("can use WAVES only at the moment")
8484 else if (!(isDefined(itemKey)))
8585 then throw("You must select Item")
8686 else {
8787 let customerAddress = toBase58String(i.caller.bytes)
8888 let price = getValueItemPrice(itemKey)
8989 let supplierAddress = getValueItemSupplier(itemKey)
9090 if ((price > pmt.amount))
9191 then throw("purchase amoun cannot be less than item price")
9292 else if ((pmt.amount > price))
9393 then throw("purchase amoun cannot be higher than item price")
9494 else if ((supplierAddress == NONE))
9595 then throw("supplier does not exist")
9696 else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
9797 }
9898 }
9999
100100
101+
102+@Callable(i)
103+func withdraw () = {
104+ let supplierAddress = toBase58String(i.caller.bytes)
105+ let balance = getValueBalanceSupplier(supplierAddress)
106+ if ((0 >= balance))
107+ then throw("no money - no honey")
108+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
109+ }
110+
111+
101112 @Verifier(tx)
102113 func verify () = {
103114 let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice))
104115 then true
105116 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyAlice))
106117 then true
107118 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyAlice))
108119 then 1
109120 else 0
110121 let signedBob = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyBob))
111122 then true
112123 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyBob))
113124 then true
114125 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyBob))
115126 then 1
116127 else 0
117128 let signedCooper = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyCooper))
118129 then true
119130 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyCooper))
120131 then true
121132 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyCooper))
122133 then 1
123134 else 0
124135 match tx {
125136 case d: SetScriptTransaction =>
126137 sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
127138 case d: DataTransaction =>
128139 true
129140 case _ =>
130141 (((signedAlice + signedBob) + signedCooper) >= 2)
131142 }
132143 }
133144

github/deemru/w8io/026f985 
23.79 ms