tx · 9184FjYaMmmKUVzh2434rMhdi5DdN4GNUv3dzTYYCa27

3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP:  -0.01400000 Waves

2021.11.18 16:23 [1796542] smart account 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP > SELF 0.00000000 Waves

{ "type": 13, "id": "9184FjYaMmmKUVzh2434rMhdi5DdN4GNUv3dzTYYCa27", "fee": 1400000, "feeAssetId": null, "timestamp": 1637241866173, "version": 2, "chainId": 84, "sender": "3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP", "senderPublicKey": "HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq", "proofs": [ "2y6PMGnbY3mgciG43YmHXdyWxsK4iaA3ZU4LBwh1U25TTJ3qCx6wac1L1jAkKR1xvjsTYc5a8UP7Hf85yvv3BGUw" ], "script": "base64:AAIDAAAAAAAAAA4IARIFCgMIAQgSAwoBCAAAABEAAAAADm93bmVyUHVibGljS2V5AQAAACD6+lAsvaY9/ICsFhS1sYMY13YGhvh1jT1AiPapnK+uIAAAAAALcHViS2V5QWxpY2UBAAAAIPr6UCy9pj38gKwWFLWxgxjXdgaG+HWNPUCI9qmcr64gAAAAAAlwdWJLZXlCb2IBAAAAIJSwJHqny7GXkLqb/9sX0sw4nnCkaYeDrScKSJwbx9dLAAAAAAxwdWJLZXlDb29wZXIBAAAAIMviW1daO0ECCbLD7je58oUri4AFkKl3dlICXnEszUFIAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAXQFAAAAByRtYXRjaDAFAAAAAXQAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIF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AnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAAxwdWJLZXlDb29wZXIGCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAMcHViS2V5Q29vcGVyBgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIFAAAADHB1YktleUNvb3BlcgAAAAAAAAAAAQAAAAAAAAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAC3NpZ25lZEFsaWNlBQAAAAlzaWduZWRCb2IFAAAADHNpZ25lZENvb3BlcgAAAAAAAAAAAlgbD7U=", "height": 1796542, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6iLkHAo7mAApY5TBX1R9KGUgrg1kpWyiJR9mVHgjVa56 Next: 4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL Diff:
OldNewDifferences
7575 }
7676
7777
78+
79+@Callable(i)
80+func purchase (itemKey) = {
81+ let pmt = extract(i.payment)
82+ if (isDefined(pmt.assetId))
83+ then throw("can use WAVES only at the moment")
84+ else if (!(isDefined(itemKey)))
85+ then throw("You must select Item")
86+ else {
87+ let customerAddress = toBase58String(i.caller.bytes)
88+ let price = getValueItemPrice(itemKey)
89+ let supplierAddress = getValueItemSupplier(itemKey)
90+ if ((price > pmt.amount))
91+ then throw("purchase amoun cannot be less than item price")
92+ else if ((pmt.amount > price))
93+ then throw("purchase amoun cannot be higher than item price")
94+ else if ((supplierAddress == NONE))
95+ then throw("supplier does not exist")
96+ else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
97+ }
98+ }
99+
100+
78101 @Verifier(tx)
79102 func verify () = {
80103 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
78+
79+@Callable(i)
80+func purchase (itemKey) = {
81+ let pmt = extract(i.payment)
82+ if (isDefined(pmt.assetId))
83+ then throw("can use WAVES only at the moment")
84+ else if (!(isDefined(itemKey)))
85+ then throw("You must select Item")
86+ else {
87+ let customerAddress = toBase58String(i.caller.bytes)
88+ let price = getValueItemPrice(itemKey)
89+ let supplierAddress = getValueItemSupplier(itemKey)
90+ if ((price > pmt.amount))
91+ then throw("purchase amoun cannot be less than item price")
92+ else if ((pmt.amount > price))
93+ then throw("purchase amoun cannot be higher than item price")
94+ else if ((supplierAddress == NONE))
95+ then throw("supplier does not exist")
96+ else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
97+ }
98+ }
99+
100+
78101 @Verifier(tx)
79102 func verify () = {
80103 let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice))
81104 then true
82105 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyAlice))
83106 then true
84107 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyAlice))
85108 then 1
86109 else 0
87110 let signedBob = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyBob))
88111 then true
89112 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyBob))
90113 then true
91114 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyBob))
92115 then 1
93116 else 0
94117 let signedCooper = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyCooper))
95118 then true
96119 else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyCooper))
97120 then true
98121 else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyCooper))
99122 then 1
100123 else 0
101124 match tx {
102125 case d: SetScriptTransaction =>
103126 sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
104127 case d: DataTransaction =>
105128 true
106129 case _ =>
107130 (((signedAlice + signedBob) + signedCooper) >= 2)
108131 }
109132 }
110133

github/deemru/w8io/026f985 
37.90 ms