tx · 4oCboyW3iKd9zTC8rQ1LM8YrYjvKXiUMDdTPVih4hYb6

3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn:  -0.01000000 Waves

2022.11.01 14:51 [2298011] smart account 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn > SELF 0.00000000 Waves

{ "type": 13, "id": "4oCboyW3iKd9zTC8rQ1LM8YrYjvKXiUMDdTPVih4hYb6", "fee": 1000000, "feeAssetId": null, "timestamp": 1667303490817, "version": 2, "chainId": 84, "sender": "3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn", "senderPublicKey": "Cq4RbcVcQJpCWyHiACDqUf2PbU8PaX949Dun9wRSeDzE", "proofs": [ "2xwtKqH7DDGnQvpvaKfUf9t1AnY44uc194r1dEbHw9HtpbkSBhRp84hmGRkQnJB8KuQt9y6P6Xt9qunZphqSe8S6" ], "script": "base64:AAIFAAAAAAAAAA0IAhIECgIICBIDCgEIAAAACgAAAAALZWdnc0Fzc2V0SWQBAAAAIP95R1BUUNh9HFX0EUDspUcxpBhcbNeBV9CDaUzAvZfwAAAAABBpbmN1YmF0b3JBZGRyZXNzAQAAABoBV4y1SJ9+nhXVGJeOG3f7CX9nYtrhbWMlSQAAAAAOZmFybWluZ0FkZHJlc3MBAAAAGgFXWxNnWQZpJ6cQTIpwvUakeLEwDJ+TjyLDAAAAABdjb2xsZWN0aXZlTWFzdGVyQWRkcmVzcwEAAAAaAVeBvXmfzjec36V8fNjMXVL07NiE2l2PcBgAAAAABXJlZjIwCQAETAAAAAICAAAAIzNQUjY2a012VURFMVF2WUFnOHI2ZTF4RFg3UWJuVFY3Slc1BQAAAANuaWwBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAEAAAATbWFzdGV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AAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAABNyZWZlcmVyQWRkcmVzc1ZhbHVlBQAAABFwYXltZW50Rm9yUmVmZXJlcgUAAAALZWdnc0Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V53ojbcw==", "height": 2298011, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6rKDqx4EXLoSJdB9fAbCQ4JWSpwHc9pMceCj5oc1jvTs Next: AwmD1VSDeLiiGkanKpCSH7z8Dk2tXBaFhA2VvYEUj9ed Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let ownerAddress = base58''
4+let eggsAssetId = base58'JCGDtrVy64cCJ1wCKfCaiNQMnyYwii71TbE5QeAHfxgF'
55
6-let nftAddress = base58''
6+let incubatorAddress = base58'3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv'
77
8-let artefactsAddress = base58''
8+let farmingAddress = base58'3PAETTtuW7aSiyKtn9GuML3RgtV1xdq1mQW'
99
10-let feeAggregator = base58''
10+let collectiveMasterAddress = base58'3PDktsxDVEcoobpEBJcausnKo4enhcWUDEF'
1111
12-let nftAssetId = base58''
12+let ref20 = ["3PR66kMvUDE1QvYAg8r6e1xDX7QbnTV7JW5"]
1313
14-let kGlobalCounter = "GLOBAL_COUNTER"
15-
16-let feePercent = 5
17-
18-let artefactsFeePercent = 20
19-
20-func tryGetInteger (key) = {
21- let val = match getInteger(this, key) {
22- case b: Int =>
23- b
24- case _ =>
25- 0
26- }
27- val
28- }
14+func tryGetInteger (key) = match getInteger(this, key) {
15+ case b: Int =>
16+ b
17+ case _ =>
18+ 0
19+}
2920
3021
31-func tryGetString (key) = {
32- let val = match getString(this, key) {
33- case b: String =>
34- b
35- case _ =>
36- ""
37- }
38- val
39- }
40-
41-
42-func tryGetBoolean (key) = match getBoolean(this, key) {
22+func masterTryGetBoolean (key) = match getBoolean(Address(collectiveMasterAddress), key) {
4323 case b: Boolean =>
4424 b
4525 case _ =>
4727 }
4828
4929
50-func getGlobalCounter () = tryGetInteger(kGlobalCounter)
30+func isValidAddress (address) = match addressFromString(address) {
31+ case a: Address =>
32+ true
33+ case _ =>
34+ false
35+}
5136
5237
53-func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(artefactsAddress)))
54- then "ART"
38+func tryGetString (key) = match getString(this, key) {
39+ case a: String =>
40+ a
41+ case _ =>
42+ ""
43+}
44+
45+
46+func getRefMultiplier (refererAddress) = if ((indexOf(ref20, refererAddress) != unit))
47+ then 4
48+ else 1
49+
50+
51+@Callable(i)
52+func addRefKey (refererAddress,refererKey) = if ((i.caller != this))
53+ then throw("admin only")
5554 else {
56- let asset1 = match getString(Address(ownerAddress), toBase58String(assetId)) {
57- case b: String =>
58- b
59- case _ =>
60- ""
61- }
62- if ((asset1 != ""))
63- then asset1
64- else {
65- let asset2 = match getString(Address(nftAddress), toBase58String(assetId)) {
66- case c: String =>
67- c
68- case _ =>
69- ""
70- }
71- if ((asset2 != ""))
72- then asset2
73- else ""
74- }
55+ let refStateKey = (("key_" + refererKey) + "_refererAddress")
56+ if ((tryGetString(refStateKey) == ""))
57+ then [StringEntry(refStateKey, refererAddress), StringEntry(((("address_" + refererAddress) + "_refererKey_") + refererKey), refererKey)]
58+ else throw((("The ref key \"" + refererKey) + "\" is already registered"))
7559 }
7660
7761
62+
7863 @Callable(i)
79-func nftBuy (nftId) = {
80- let isnftart = tryGetBoolean((("nft_" + nftId) + "_nftart"))
81- let paymentAssetId = if ((isnftart == true))
82- then nftAssetId
83- else unit
84- let paymentAssetName = if ((isnftart == true))
85- then "nftart"
86- else "WAVES"
87- let pmt = value(i.payments[0])
88- let amount = pmt.amount
89- let assetId = tryGetString((("nft_" + nftId) + "_assetId"))
90- let bidId = toBase58String(i.transactionId)
91- let nftStatus = tryGetString((("nft_" + nftId) + "_status"))
92- let finalFee = if ((tryGetBoolean((("nft_" + nftId) + "_isArtefact")) == true))
93- then artefactsFeePercent
94- else feePercent
95- if ((pmt.assetId != paymentAssetId))
96- then throw((("nft does only support " + paymentAssetName) + " payments."))
97- else if ((nftStatus != "open"))
98- then throw("nft is closed. You cannot place a bid.")
99- else {
100- let instantPrice = tryGetInteger((("nft_" + nftId) + "_instantPrice"))
101- if ((instantPrice > amount))
102- then throw(("For instant purchase you need to pay at least " + toString(instantPrice)))
103- else {
104- let nftOwner = tryGetString((("nft_" + nftId) + "_owner"))
105- let recordPrice = tryGetInteger((assetId + "_recordPrice"))
106- let newRecordPrice = max([recordPrice, amount])
107-[StringEntry((("nft_" + nftId) + "_status"), "finished"), IntegerEntry((("nft_" + nftId) + "_finalPrice"), amount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"nftId\": \"" + nftId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(amount)) + "\", \"status\": \"finished\"}")), DeleteEntry((((("address_" + nftOwner) + "_nft_") + nftId) + "_lockedNFT")), ScriptTransfer(i.originCaller, 1, fromBase58String(getStringValue(this, (("nft_" + nftId) + "_assetId")))), ScriptTransfer(addressFromStringValue(nftOwner), fraction(amount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(feeAggregator), fraction(amount, finalFee, 100), paymentAssetId)]
108- }
109- }
64+func refPayment (refererKey) = {
65+ let referalAddress = toString(i.originCaller)
66+ if (if ((i.caller.bytes != incubatorAddress))
67+ then (i.caller.bytes != farmingAddress)
68+ else false)
69+ then throw("This method can be called only by farming and incubator dApps")
70+ else if (if ((refererKey == ""))
71+ then (tryGetString((("address_" + referalAddress) + "_referedBy")) == "")
72+ else false)
73+ then nil
74+ else if (masterTryGetBoolean(("farm_" + referalAddress)))
75+ then nil
76+ else {
77+ let givenReferer = match getString(this, (("key_" + refererKey) + "_refererAddress")) {
78+ case x: String =>
79+ x
80+ case _ =>
81+ refererKey
82+ }
83+ let refererAddress = match getString(this, (("address_" + referalAddress) + "_referedBy")) {
84+ case x: String =>
85+ x
86+ case _ =>
87+ givenReferer
88+ }
89+ let refAmount = (i.payments[0].amount * getRefMultiplier(refererAddress))
90+ if ((addressFromString(refererAddress) == unit))
91+ then nil
92+ else {
93+ let refererAddressValue = addressFromStringValue(refererAddress)
94+ let referalAddressValue = addressFromStringValue(referalAddress)
95+ let paymentForReferer = refAmount
96+ let refererEarnedReward = (("address_" + refererAddress) + "_earnedReward")
97+ let referalDeliveredReward = (((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_deliveredReward")
98+ if ((refererAddress == referalAddress))
99+ then nil
100+ else [StringEntry((("address_" + referalAddress) + "_referedBy"), refererAddress), IntegerEntry(refererEarnedReward, (tryGetInteger(refererEarnedReward) + paymentForReferer)), IntegerEntry(referalDeliveredReward, (tryGetInteger(referalDeliveredReward) + paymentForReferer)), IntegerEntry((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount"), (tryGetInteger((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount")) + 1)), ScriptTransfer(refererAddressValue, paymentForReferer, eggsAssetId)]
101+ }
102+ }
110103 }
111104
105+
106+@Verifier(tx)
107+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
112108
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let ownerAddress = base58''
4+let eggsAssetId = base58'JCGDtrVy64cCJ1wCKfCaiNQMnyYwii71TbE5QeAHfxgF'
55
6-let nftAddress = base58''
6+let incubatorAddress = base58'3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv'
77
8-let artefactsAddress = base58''
8+let farmingAddress = base58'3PAETTtuW7aSiyKtn9GuML3RgtV1xdq1mQW'
99
10-let feeAggregator = base58''
10+let collectiveMasterAddress = base58'3PDktsxDVEcoobpEBJcausnKo4enhcWUDEF'
1111
12-let nftAssetId = base58''
12+let ref20 = ["3PR66kMvUDE1QvYAg8r6e1xDX7QbnTV7JW5"]
1313
14-let kGlobalCounter = "GLOBAL_COUNTER"
15-
16-let feePercent = 5
17-
18-let artefactsFeePercent = 20
19-
20-func tryGetInteger (key) = {
21- let val = match getInteger(this, key) {
22- case b: Int =>
23- b
24- case _ =>
25- 0
26- }
27- val
28- }
14+func tryGetInteger (key) = match getInteger(this, key) {
15+ case b: Int =>
16+ b
17+ case _ =>
18+ 0
19+}
2920
3021
31-func tryGetString (key) = {
32- let val = match getString(this, key) {
33- case b: String =>
34- b
35- case _ =>
36- ""
37- }
38- val
39- }
40-
41-
42-func tryGetBoolean (key) = match getBoolean(this, key) {
22+func masterTryGetBoolean (key) = match getBoolean(Address(collectiveMasterAddress), key) {
4323 case b: Boolean =>
4424 b
4525 case _ =>
4626 false
4727 }
4828
4929
50-func getGlobalCounter () = tryGetInteger(kGlobalCounter)
30+func isValidAddress (address) = match addressFromString(address) {
31+ case a: Address =>
32+ true
33+ case _ =>
34+ false
35+}
5136
5237
53-func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(artefactsAddress)))
54- then "ART"
38+func tryGetString (key) = match getString(this, key) {
39+ case a: String =>
40+ a
41+ case _ =>
42+ ""
43+}
44+
45+
46+func getRefMultiplier (refererAddress) = if ((indexOf(ref20, refererAddress) != unit))
47+ then 4
48+ else 1
49+
50+
51+@Callable(i)
52+func addRefKey (refererAddress,refererKey) = if ((i.caller != this))
53+ then throw("admin only")
5554 else {
56- let asset1 = match getString(Address(ownerAddress), toBase58String(assetId)) {
57- case b: String =>
58- b
59- case _ =>
60- ""
61- }
62- if ((asset1 != ""))
63- then asset1
64- else {
65- let asset2 = match getString(Address(nftAddress), toBase58String(assetId)) {
66- case c: String =>
67- c
68- case _ =>
69- ""
70- }
71- if ((asset2 != ""))
72- then asset2
73- else ""
74- }
55+ let refStateKey = (("key_" + refererKey) + "_refererAddress")
56+ if ((tryGetString(refStateKey) == ""))
57+ then [StringEntry(refStateKey, refererAddress), StringEntry(((("address_" + refererAddress) + "_refererKey_") + refererKey), refererKey)]
58+ else throw((("The ref key \"" + refererKey) + "\" is already registered"))
7559 }
7660
7761
62+
7863 @Callable(i)
79-func nftBuy (nftId) = {
80- let isnftart = tryGetBoolean((("nft_" + nftId) + "_nftart"))
81- let paymentAssetId = if ((isnftart == true))
82- then nftAssetId
83- else unit
84- let paymentAssetName = if ((isnftart == true))
85- then "nftart"
86- else "WAVES"
87- let pmt = value(i.payments[0])
88- let amount = pmt.amount
89- let assetId = tryGetString((("nft_" + nftId) + "_assetId"))
90- let bidId = toBase58String(i.transactionId)
91- let nftStatus = tryGetString((("nft_" + nftId) + "_status"))
92- let finalFee = if ((tryGetBoolean((("nft_" + nftId) + "_isArtefact")) == true))
93- then artefactsFeePercent
94- else feePercent
95- if ((pmt.assetId != paymentAssetId))
96- then throw((("nft does only support " + paymentAssetName) + " payments."))
97- else if ((nftStatus != "open"))
98- then throw("nft is closed. You cannot place a bid.")
99- else {
100- let instantPrice = tryGetInteger((("nft_" + nftId) + "_instantPrice"))
101- if ((instantPrice > amount))
102- then throw(("For instant purchase you need to pay at least " + toString(instantPrice)))
103- else {
104- let nftOwner = tryGetString((("nft_" + nftId) + "_owner"))
105- let recordPrice = tryGetInteger((assetId + "_recordPrice"))
106- let newRecordPrice = max([recordPrice, amount])
107-[StringEntry((("nft_" + nftId) + "_status"), "finished"), IntegerEntry((("nft_" + nftId) + "_finalPrice"), amount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"nftId\": \"" + nftId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(amount)) + "\", \"status\": \"finished\"}")), DeleteEntry((((("address_" + nftOwner) + "_nft_") + nftId) + "_lockedNFT")), ScriptTransfer(i.originCaller, 1, fromBase58String(getStringValue(this, (("nft_" + nftId) + "_assetId")))), ScriptTransfer(addressFromStringValue(nftOwner), fraction(amount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(feeAggregator), fraction(amount, finalFee, 100), paymentAssetId)]
108- }
109- }
64+func refPayment (refererKey) = {
65+ let referalAddress = toString(i.originCaller)
66+ if (if ((i.caller.bytes != incubatorAddress))
67+ then (i.caller.bytes != farmingAddress)
68+ else false)
69+ then throw("This method can be called only by farming and incubator dApps")
70+ else if (if ((refererKey == ""))
71+ then (tryGetString((("address_" + referalAddress) + "_referedBy")) == "")
72+ else false)
73+ then nil
74+ else if (masterTryGetBoolean(("farm_" + referalAddress)))
75+ then nil
76+ else {
77+ let givenReferer = match getString(this, (("key_" + refererKey) + "_refererAddress")) {
78+ case x: String =>
79+ x
80+ case _ =>
81+ refererKey
82+ }
83+ let refererAddress = match getString(this, (("address_" + referalAddress) + "_referedBy")) {
84+ case x: String =>
85+ x
86+ case _ =>
87+ givenReferer
88+ }
89+ let refAmount = (i.payments[0].amount * getRefMultiplier(refererAddress))
90+ if ((addressFromString(refererAddress) == unit))
91+ then nil
92+ else {
93+ let refererAddressValue = addressFromStringValue(refererAddress)
94+ let referalAddressValue = addressFromStringValue(referalAddress)
95+ let paymentForReferer = refAmount
96+ let refererEarnedReward = (("address_" + refererAddress) + "_earnedReward")
97+ let referalDeliveredReward = (((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_deliveredReward")
98+ if ((refererAddress == referalAddress))
99+ then nil
100+ else [StringEntry((("address_" + referalAddress) + "_referedBy"), refererAddress), IntegerEntry(refererEarnedReward, (tryGetInteger(refererEarnedReward) + paymentForReferer)), IntegerEntry(referalDeliveredReward, (tryGetInteger(referalDeliveredReward) + paymentForReferer)), IntegerEntry((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount"), (tryGetInteger((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount")) + 1)), ScriptTransfer(refererAddressValue, paymentForReferer, eggsAssetId)]
101+ }
102+ }
110103 }
111104
105+
106+@Verifier(tx)
107+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
112108

github/deemru/w8io/026f985 
27.48 ms