tx · 55hNEsKebyqGS8vCw8oeiuQCqf4PRUB5yBvh7WwQxZQG

3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3:  -0.01400000 Waves

2020.11.20 18:23 [1273880] smart account 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3 > SELF 0.00000000 Waves

{ "type": 13, "id": "55hNEsKebyqGS8vCw8oeiuQCqf4PRUB5yBvh7WwQxZQG", "fee": 1400000, "feeAssetId": null, "timestamp": 1605885849843, "version": 2, "chainId": 84, "sender": "3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3", "senderPublicKey": "24o2mnMP6y64dijDFoZKhDpV73e1gCFKxQcZ6X9q3z1B", "proofs": [ "52S2y4Ah2Cca94URVJGzvuHvqhovhvXARUkvVtNGKdUNwSWdE4rfDSQ9hV2NrsNgJ8DfUqnGSEEKt3634veMdKHg" ], "script": "base64:AAIEAAAAAAAAABAIAhIDCgEIEgUKAwgBCBIAAAAAEAAAAAARYWNjb3VudDFQdWJsaWNLZXkBAAAAIPeNeDDs4TWVhR1bzOk94lFsHOraL9B/FRj0XfVMj0hOAAAAABFhY2NvdW50MlB1YmxpY0tleQEAAAAgG1e/aEwKrtMkcq9WyiLLAHtKPJgLd/oAoUXcKuUDIhUAAAAADm90aGVyUHVibGljS2V5AQAAACDnblGJprjxGAm9jEz8V5M0TOEG6bhNvbMQquBNrx0dWgAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIF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ckVudHJ5AAAAAgkBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEFAAAABGl0ZW0FAAAABXByaWNlCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEFAAAABGl0ZW0FAAAABGRhdGEFAAAAA25pbAAAAAFpAQAAAAh3aXRoZHJhdwAAAAAEAAAAD3N1cHBsaWVyQWRkcmVzcwkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAdiYWxhbmNlCQEAAAAXZ2V0VmFsdWVCYWxhbmNlU3VwcGxpZXIAAAABBQAAAA9zdXBwbGllckFkZHJlc3MDCQAAZwAAAAIAAAAAAAAAAAAFAAAAB2JhbGFuY2UJAAACAAAAAQIAAAAUaW5zdWZmaWNpZW50IGJhbGFuY2UJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABVnZXRLZXlCYWxhbmNlU3VwcGxpZXIAAAABBQAAAA9zdXBwbGllckFkZHJlc3MAAAAAAAAAAAAJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzBQAAAAdiYWxhbmNlBQAAAAR1bml0BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABq7Ojcw=", "height": 1273880, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5RyV7rb3i2oC27HBC9Zwh8vCFeLLQb85bpyJ2UgXuJvr Next: 8jmkyYve2ey2uqgxv62N2sSstm4jUoBKbW8Pthdjgeqd Diff:
OldNewDifferences
9696 }
9797
9898
99+
100+@Callable(i)
101+func withdraw () = {
102+ let supplierAddress = toBase58String(i.caller.bytes)
103+ let balance = getValueBalanceSupplier(supplierAddress)
104+ if ((0 >= balance))
105+ then throw("insufficient balance")
106+ else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
107+ }
108+
109+
99110 @Verifier(tx)
100111 func verify () = true
101112
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd'
55
66 let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv'
77
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
99
1010 let NONE = "none"
1111
1212 func getNumberByKey (key) = {
1313 let num = match getInteger(this, key) {
1414 case a: Int =>
1515 a
1616 case _ =>
1717 0
1818 }
1919 num
2020 }
2121
2222
2323 func getStrByKey (key) = {
2424 let str = match getString(this, key) {
2525 case a: String =>
2626 a
2727 case _ =>
2828 NONE
2929 }
3030 str
3131 }
3232
3333
3434 func getKeyItemPrice (item) = (item + "_price")
3535
3636
3737 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3838
3939
4040 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4141
4242
4343 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4444
4545
4646 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4747
4848
4949 func getKeyItemData (item) = (item + "_data")
5050
5151
5252 func getKeyItemSupplier (item) = (item + "_owner")
5353
5454
5555 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5656
5757
5858 func getKeyBalanceSupplier (account) = (account + "_balance")
5959
6060
6161 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6262
6363
6464 @Callable(i)
6565 func purchase (item) = {
6666 let pmt = value(i.payments)
6767 if (isDefined(pmt[0].assetId))
6868 then throw("WAVES tokens only")
6969 else {
7070 let userAddress = toBase58String(i.caller.bytes)
7171 let price = getValueItemPrice(item)
7272 let supplierAddress = getValueItemSupplier(item)
7373 if ((price > pmt[0].amount))
7474 then throw("purchase less than item price")
7575 else if ((pmt[0].amount > price))
7676 then throw("purchase amount higher than item price")
7777 else if ((size(pmt) > 1))
7878 then throw("single item only")
7979 else if ((supplierAddress == NONE))
8080 then throw("supplier doesn't exist")
8181 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt[0].amount))]
8282 }
8383 }
8484
8585
8686
8787 @Callable(i)
8888 func addItem (title,price,data) = {
8989 let supplierAddress = toBase58String(i.caller.bytes)
9090 let item = getKeyItem(supplierAddress, title)
9191 if ((0 >= price))
9292 then throw("purchase amount cannot be less than item price")
9393 else if ((getValueItemSupplier(item) != NONE))
9494 then throw("an item already exist")
9595 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
9696 }
9797
9898
99+
100+@Callable(i)
101+func withdraw () = {
102+ let supplierAddress = toBase58String(i.caller.bytes)
103+ let balance = getValueBalanceSupplier(supplierAddress)
104+ if ((0 >= balance))
105+ then throw("insufficient balance")
106+ else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
107+ }
108+
109+
99110 @Verifier(tx)
100111 func verify () = true
101112

github/deemru/w8io/169f3d6 
24.74 ms