tx · DT1QFW3cn7yjMrqJAARvMdkh2ww2LpMqqrK9zcfR1ndp

3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r:  -0.04000000 Waves

2022.01.13 17:35 [1877307] smart account 3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r > SELF 0.00000000 Waves

{ "type": 13, "id": "DT1QFW3cn7yjMrqJAARvMdkh2ww2LpMqqrK9zcfR1ndp", "fee": 4000000, "feeAssetId": null, "timestamp": 1642084535203, "version": 2, "chainId": 84, "sender": "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r", "senderPublicKey": "GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY", "proofs": [ "5PqVxJt4v9UQxVv6H9NTErCmmmp2FeUGHPaW39Jkop8h48PZ7Hek1N84N3wsSN6eyqzLUR8LKUEWguoqcbPYoT5V" ], "script": "base64:AAIFAAAAAAAAATsIAhIFCgMICAgSAwoBCBoXCgFhEhJob2xkaW5nc0FkZHJlc3NTdHIaFgoBYhIRaG9sZGluZ3NQdWJsaWNLZXkaFAoBYxIPaG9sZGluZ3NBZGRyZXNzGhQKAWQSD3RyYW5zZmVyQ29zdFBjdBoGCgFlEgFpGgwKAWYSB293bmVySWQaDAoBZxIHYXNzZXRJZBoLCgFoEgZhbW91bnQaDAoBaRIHJG1hdGNoMBoGCgFqEgF4GhIKAWsSDXBheW1lbnRBbW91bnQaHQoBbBIYYW1vdW50VG9SZW1haW5JbkhvbGRpbmdzGhwKAW0SF2Ftb3VudFRvVHJhbnNmZXJUb093bmVyGg0KAW4SCHRyYW5zZmVyGhEKAW8SDG93bmVyQWRkcmVzcxoHCgFwEgJ0eBoLCgFxEgZ2ZXJpZnkAAAAEAAAAAAFhAgAAACMzTjlSN3U0NDlaMWI3NlFwSnA5dTNnelBqTVlRWW5wM1Y3cgAAAAABYgEAAAAg5d0hRbOj7Efpajd5Rdd2peneLysI9sOzTPgBiZfQ228AAAAAAWMJAQAAABRhZGRyZXNzRn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AIAAAABAgAAABlPcmlnaW5hbCBvd25lciBub3QgZm91bmQgAwMJAAAAAAAAAgUAAAABaAAAAAAAAAAAAAYJAABmAAAAAgUAAAABaAUAAAABawkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAADNQYXltZW50IGFuZCBhbW91bnQgZG8gbm90IG1hdGNoLiBUaGlzIGFzc2V0cyBjb3N0cyAJAAGkAAAAAQUAAAABaAIAAAANYnV0IHlvdSBzZW50IAkAAaQAAAABBQAAAAFrBAAAAAFsCQAAaAAAAAIFAAAAAWsJAABpAAAAAgUAAAABZAAAAAAAAAAD6AQAAAABbQkAAGUAAAACBQAAAAFrBQAAAAFsBAAAAAFuCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFlAAAABmNhbGxlcgAAAAAAAAAAAQkAAlkAAAABBQAAAAFnBQAAAANuaWwDCQEAAAACIT0AAAACBQAAAAFmBQAAAAFhBAAAAAFvCQEAAAAHQWRkcmVzcwAAAAEJAAJZAAAAAQUAAAABZgkABE4AAAACBQAAAAFuCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAAW8FAAAAAW0FAAAABHVuaXQFAAAAA25pbAUAAAABbgAAAAEAAAABcAEAAAABcQAAAAAJAAH0AAAAAwgFAAAAAXAAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAFwAAAABnByb29mcwAAAAAAAAAAAAgFAAAAAXAAAAAPc2VuZGVyUHVibGljS2V5lS2u4Q==", "height": 1877307, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HhqFXZzuydjAad3oFCbkTC72rNiyrtN7iCYAjGL5fA1k Next: Aad4hQWXYVbtVfmKtxEXVDjdX9r6wPmi2nzyNG4MBtBK Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
5+
46 let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY'
57
68 let holdingsAddress = addressFromPublicKey(holdingsPublicKey)
4042 else {
4143 let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000))
4244 let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings)
43- let ownerAddress = Address(fromBase58String(ownerId))
44-[ScriptTransfer(i.caller, 1, fromBase58String(assetId)), ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)]
45+ let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId))]
46+ if ((ownerId != holdingsAddressStr))
47+ then {
48+ let ownerAddress = Address(fromBase58String(ownerId))
49+ (transfer ++ [ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)])
50+ }
51+ else transfer
4552 }
4653 }
4754
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
5+
46 let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY'
57
68 let holdingsAddress = addressFromPublicKey(holdingsPublicKey)
79
810 let transferCostPct = 25
911
1012 @Callable(i)
1113 func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount)]
1214
1315
1416
1517 @Callable(i)
1618 func buyFromHoldings (assetId) = {
1719 let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) {
1820 case _: Unit =>
1921 "unset"
2022 case x: String =>
2123 x
2224 case _ =>
2325 throw("Match error")
2426 }
2527 let paymentAmount = valueOrElse(i.payments[0].amount, 0)
2628 let amount = match getString(this, (("sale_" + assetId) + "_amount")) {
2729 case _: Unit =>
2830 0
2931 case x: String =>
3032 (valueOrElse(parseInt(x), 0) * 100000000)
3133 case _ =>
3234 throw("Match error")
3335 }
3436 if ((ownerId == "unset"))
3537 then throw("Original owner not found ")
3638 else if (if ((amount == 0))
3739 then true
3840 else (amount > paymentAmount))
3941 then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount)))
4042 else {
4143 let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000))
4244 let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings)
43- let ownerAddress = Address(fromBase58String(ownerId))
44-[ScriptTransfer(i.caller, 1, fromBase58String(assetId)), ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)]
45+ let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId))]
46+ if ((ownerId != holdingsAddressStr))
47+ then {
48+ let ownerAddress = Address(fromBase58String(ownerId))
49+ (transfer ++ [ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)])
50+ }
51+ else transfer
4552 }
4653 }
4754
4855
4956 @Verifier(tx)
5057 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
5158

github/deemru/w8io/169f3d6 
25.44 ms