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:AAIFAAAAAAAAATsIAhIFCgMICAgSAwoBCBoXCgFhEhJob2xkaW5nc0FkZHJlc3NTdHIaFgoBYhIRaG9sZGluZ3NQdWJsaWNLZXkaFAoBYxIPaG9sZGluZ3NBZGRyZXNzGhQKAWQSD3RyYW5zZmVyQ29zdFBjdBoGCgFlEgFpGgwKAWYSB293bmVySWQaDAoBZxIHYXNzZXRJZBoLCgFoEgZhbW91bnQaDAoBaRIHJG1hdGNoMBoGCgFqEgF4GhIKAWsSDXBheW1lbnRBbW91bnQaHQoBbBIYYW1vdW50VG9SZW1haW5JbkhvbGRpbmdzGhwKAW0SF2Ftb3VudFRvVHJhbnNmZXJUb093bmVyGg0KAW4SCHRyYW5zZmVyGhEKAW8SDG93bmVyQWRkcmVzcxoHCgFwEgJ0eBoLCgFxEgZ2ZXJpZnkAAAAEAAAAAAFhAgAAACMzTjlSN3U0NDlaMWI3NlFwSnA5dTNnelBqTVlRWW5wM1Y3cgAAAAABYgEAAAAg5d0hRbOj7Efpajd5Rdd2peneLysI9sOzTPgBiZfQ228AAAAAAWMJAQAAABRhZGRyZXNzRnJ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IAAAABAgAAABlPcmlnaW5hbCBvd25lciBub3QgZm91bmQgAwMJAAAAAAAAAgUAAAABaAAAAAAAAAAAAAYJAABmAAAAAgUAAAABaAUAAAABawkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAADNQYXltZW50IGFuZCBhbW91bnQgZG8gbm90IG1hdGNoLiBUaGlzIGFzc2V0cyBjb3N0cyAJAAGkAAAAAQUAAAABaAIAAAANYnV0IHlvdSBzZW50IAkAAaQAAAABBQAAAAFrBAAAAAFsCQAAaAAAAAIFAAAAAWsJAABpAAAAAgUAAAABZAAAAAAAAAAD6AQAAAABbQkAAGUAAAACBQAAAAFrBQAAAAFsBAAAAAFuCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFlAAAABmNhbGxlcgAAAAAAAAAAAQkAAlkAAAABBQAAAAFnBQAAAANuaWwDCQEAAAACIT0AAAACBQAAAAFmBQAAAAFhBAAAAAFvCQEAAAAHQWRkcmVzcwAAAAEJAAJZAAAAAQUAAAABZgkABE4AAAACBQAAAAFuCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAAW8FAAAAAW0FAAAABHVuaXQFAAAAA25pbAUAAAABbgAAAAEAAAABcAEAAAABcQAAAAAJAAH0AAAAAwgFAAAAAXAAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAFwAAAABnByb29mcwAAAAAAAAAAAAgFAAAAAXAAAAAPc2VuZGVyUHVibGljS2V5lS2u4Q==", "height": 1877307, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HhqFXZzuydjAad3oFCbkTC72rNiyrtN7iCYAjGL5fA1k Next: Aad4hQWXYVbtVfmKtxEXVDjdX9r6wPmi2nzyNG4MBtBK Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r" | |
5 | + | ||
4 | 6 | let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY' | |
5 | 7 | ||
6 | 8 | let holdingsAddress = addressFromPublicKey(holdingsPublicKey) | |
40 | 42 | else { | |
41 | 43 | let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000)) | |
42 | 44 | 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 | |
45 | 52 | } | |
46 | 53 | } | |
47 | 54 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r" | |
5 | + | ||
4 | 6 | let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY' | |
5 | 7 | ||
6 | 8 | let holdingsAddress = addressFromPublicKey(holdingsPublicKey) | |
7 | 9 | ||
8 | 10 | let transferCostPct = 25 | |
9 | 11 | ||
10 | 12 | @Callable(i) | |
11 | 13 | func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount)] | |
12 | 14 | ||
13 | 15 | ||
14 | 16 | ||
15 | 17 | @Callable(i) | |
16 | 18 | func buyFromHoldings (assetId) = { | |
17 | 19 | let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) { | |
18 | 20 | case _: Unit => | |
19 | 21 | "unset" | |
20 | 22 | case x: String => | |
21 | 23 | x | |
22 | 24 | case _ => | |
23 | 25 | throw("Match error") | |
24 | 26 | } | |
25 | 27 | let paymentAmount = valueOrElse(i.payments[0].amount, 0) | |
26 | 28 | let amount = match getString(this, (("sale_" + assetId) + "_amount")) { | |
27 | 29 | case _: Unit => | |
28 | 30 | 0 | |
29 | 31 | case x: String => | |
30 | 32 | (valueOrElse(parseInt(x), 0) * 100000000) | |
31 | 33 | case _ => | |
32 | 34 | throw("Match error") | |
33 | 35 | } | |
34 | 36 | if ((ownerId == "unset")) | |
35 | 37 | then throw("Original owner not found ") | |
36 | 38 | else if (if ((amount == 0)) | |
37 | 39 | then true | |
38 | 40 | else (amount > paymentAmount)) | |
39 | 41 | then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount))) | |
40 | 42 | else { | |
41 | 43 | let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000)) | |
42 | 44 | 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 | |
45 | 52 | } | |
46 | 53 | } | |
47 | 54 | ||
48 | 55 | ||
49 | 56 | @Verifier(tx) | |
50 | 57 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
51 | 58 |
github/deemru/w8io/169f3d6 25.44 ms ◑