tx · CrwXXfUoWCYXC7pWT61hJjAtCPERRzq3nahKWGdgaArt 3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H: -0.00600000 Waves 2022.06.18 20:23 [2102108] smart account 3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H > SELF 0.00000000 Waves
{ "type": 13, "id": "CrwXXfUoWCYXC7pWT61hJjAtCPERRzq3nahKWGdgaArt", "fee": 600000, "feeAssetId": null, "timestamp": 1655573053965, "version": 2, "chainId": 84, "sender": "3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H", "senderPublicKey": "69Rez9g3wdeHPiCsmjaaaK1GBhFjL79pxMPX9Fpk8S5e", "proofs": [ "4SwsupLtVAR3S3THZCpwjKUinNG5FJnKQuFM2U2F6bjQtZumFHsGyPoU4EcmKxTNQ7XgCrLW3bfzWRrWGpzTtsJm" ], "script": "base64:AAIFAAAAAAAAAA4IAhIFCgMIAQESAwoBCAAAABMAAAAAA1NFUAIAAAACX18AAAAABU1VTFQ2AAAAAAAAD0JAAAAAAAVNVUxUOAAAAAAABfXhAAAAAAAKQU5PVEVJRFNUUgIAAAAFV0FWRVMAAAAAB0FOT1RFSUQJAAJZAAAAAQUAAAAKQU5PVEVJRFNUUgEAAAAMZ2V0SW50T3JGYWlsAAAAAQAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACAgAAAA9NYW5kYXRvcnkgdGhpcy4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAQAAAAxnZXRTdHJPckVsc2UAAAACAAAAA2tleQAAAApkZWZhdWx0VmFsCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQUAAAAKZGVmYXVsdFZhbAEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAQAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb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aW9uSWQFAAAACG1pbmVkQW10BQAAAA1iZW5pZmljYXJ5QW10BQAAAAtwcm90b2NvbEFtdAkABEwAAAACCQEAAAARUmV3YXJkVG90YWxzRW50cnkAAAAEBQAAAAxtaW5lckFkZHJlc3MFAAAACG1pbmVkQW10BQAAAA1iZW5pZmljYXJ5QW10BQAAAAtwcm90b2NvbEFtdAUAAAADbmlsAAAAAGyo2mQ=", "height": 2102108, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5LXxyoMZZd3K8XBeAVhYiRVG4dvuBASV7vqXTsjNeEms Next: EZ7ZwQuqipLSipS5WukT7hjpMmL83fAS8P8k3qEszpLg Diff:
Old | New | Differences | |
---|---|---|---|
37 | 37 | func keyAnoteAddressStr () = "%s%s__cfg__anoteAddress" | |
38 | 38 | ||
39 | 39 | ||
40 | - | func keyMasterNodeAddressStr () = "%s%s__cfg__mainAnoteNodeAddress" | |
41 | - | ||
42 | - | ||
43 | 40 | func keyProtocolPartX6 () = "%s%s__cfg__protocolPartX6" | |
44 | 41 | ||
45 | 42 | ||
49 | 46 | func keyRewardHistory (nodeAddress,txId) = makeString(["%s%s%s", "history", toString(nodeAddress), toBase58String(txId)], SEP) | |
50 | 47 | ||
51 | 48 | ||
52 | - | func dataRewardHistory (anoteAmountTotal,beneficiaryAmt,protocolAmt | |
49 | + | func dataRewardHistory (anoteAmountTotal,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(anoteAmountTotal), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
53 | 50 | ||
54 | 51 | ||
55 | - | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt | |
52 | + | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt) = StringEntry(keyRewardHistory(nodeAddress, txId), dataRewardHistory(minedAmt, beneficiaryAmt, protocolAmt)) | |
56 | 53 | ||
57 | 54 | ||
58 | - | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt | |
55 | + | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d", toString(minedAmt), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
59 | 56 | ||
60 | 57 | ||
61 | - | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt | |
58 | + | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt) = { | |
62 | 59 | let nodeRewardsTotalsKEY = keyNodeRewardsTotals(toString(miner)) | |
63 | - | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0 | |
60 | + | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0)), SEP) | |
64 | 61 | let newMinedAmt = (parseIntValue(nodeRewardsArray[1]) + minedAmt) | |
65 | 62 | let newBeneficiaryAmt = (parseIntValue(nodeRewardsArray[2]) + beneficiaryAmt) | |
66 | 63 | let newProtocolAmt = (parseIntValue(nodeRewardsArray[3]) + protocolAmt) | |
67 | - | let newProtocolAmtPart1 = (parseIntValue(nodeRewardsArray[4]) + protocolAmtPart1) | |
68 | - | let newProtocolAmtPart2 = (parseIntValue(nodeRewardsArray[5]) + protocolAmtPart2) | |
69 | - | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt, newProtocolAmtPart1, newProtocolAmtPart2)) | |
64 | + | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt)) | |
70 | 65 | } | |
71 | 66 | ||
72 | 67 | ||
73 | 68 | @Callable(i) | |
74 | - | func constructor (anoteAddressStr | |
69 | + | func constructor (anoteAddressStr,protocolPartX6,benificaryPartX6) = if ((i.caller != this)) | |
75 | 70 | then throw("permissions denied") | |
76 | 71 | else if ((0 > protocolPartX6)) | |
77 | 72 | then throw("protocolPartX6 less then zero") | |
79 | 74 | then throw("benificaryPartX6 less then zero") | |
80 | 75 | else if (((protocolPartX6 + benificaryPartX6) != MULT6)) | |
81 | 76 | then throw("parts sum must be 1") | |
82 | - | else [StringEntry(keyAnoteAddressStr(), validateAddressOrFail(anoteAddressStr)), | |
77 | + | else [StringEntry(keyAnoteAddressStr(), validateAddressOrFail(anoteAddressStr)), IntegerEntry(keyProtocolPartX6(), protocolPartX6), IntegerEntry(keyBenificaryPartX6(), benificaryPartX6)] | |
83 | 78 | ||
84 | 79 | ||
85 | 80 | ||
102 | 97 | then throw("fee amount couldn't exceed 0.005") | |
103 | 98 | else { | |
104 | 99 | let anoteAddress = getAddressOrFail(keyAnoteAddressStr()) | |
105 | - | let masterNodeAddress = getAddressOrFail(keyMasterNodeAddressStr()) | |
106 | 100 | let minerAddress = i.caller | |
107 | 101 | let benificaryAddress = addressFromStringValue(benificaryAddressStr) | |
108 | 102 | let protocolPart = getIntOrFail(keyProtocolPartX6()) | |
113 | 107 | else { | |
114 | 108 | let benificaryAmt = fraction(minedAmt, benificaryPart, MULT6) | |
115 | 109 | let protocolAmt = (minedAmt - benificaryAmt) | |
116 | - | let protocolAmt1 = (protocolAmt / 2) | |
117 | - | let protocolAmt2 = (protocolAmt - protocolAmt1) | |
118 | - | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(anoteAddress, protocolAmt1, unit), ScriptTransfer(masterNodeAddress, protocolAmt2, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2)] | |
110 | + | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(anoteAddress, protocolAmt, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt)] | |
119 | 111 | } | |
120 | 112 | } | |
121 | 113 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let MULT6 = 1000000 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let ANOTEIDSTR = "WAVES" | |
11 | 11 | ||
12 | 12 | let ANOTEID = fromBase58String(ANOTEIDSTR) | |
13 | 13 | ||
14 | 14 | func getIntOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("Mandatory this." + key) + " is not defined")) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("Mandatory this." + key) + " is not defined")) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStringOrFail(key)), (("Fail to convert this." + key) + " value into Address")) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func validateAddressOrFail (addressStr) = { | |
27 | 27 | let address = valueOrErrorMessage(addressFromString(addressStr), ("fail to convert into address " + addressStr)) | |
28 | 28 | if ((0 > wavesBalance(address).available)) | |
29 | 29 | then throw() | |
30 | 30 | else addressStr | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func keyNodeRewardsTotals (address) = ("%s%s__totals__" + address) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyAnoteAddressStr () = "%s%s__cfg__anoteAddress" | |
38 | 38 | ||
39 | 39 | ||
40 | - | func keyMasterNodeAddressStr () = "%s%s__cfg__mainAnoteNodeAddress" | |
41 | - | ||
42 | - | ||
43 | 40 | func keyProtocolPartX6 () = "%s%s__cfg__protocolPartX6" | |
44 | 41 | ||
45 | 42 | ||
46 | 43 | func keyBenificaryPartX6 () = "%s%s__cfg__benificaryPartX6" | |
47 | 44 | ||
48 | 45 | ||
49 | 46 | func keyRewardHistory (nodeAddress,txId) = makeString(["%s%s%s", "history", toString(nodeAddress), toBase58String(txId)], SEP) | |
50 | 47 | ||
51 | 48 | ||
52 | - | func dataRewardHistory (anoteAmountTotal,beneficiaryAmt,protocolAmt | |
49 | + | func dataRewardHistory (anoteAmountTotal,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(anoteAmountTotal), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
53 | 50 | ||
54 | 51 | ||
55 | - | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt | |
52 | + | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt) = StringEntry(keyRewardHistory(nodeAddress, txId), dataRewardHistory(minedAmt, beneficiaryAmt, protocolAmt)) | |
56 | 53 | ||
57 | 54 | ||
58 | - | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt | |
55 | + | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d", toString(minedAmt), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
59 | 56 | ||
60 | 57 | ||
61 | - | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt | |
58 | + | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt) = { | |
62 | 59 | let nodeRewardsTotalsKEY = keyNodeRewardsTotals(toString(miner)) | |
63 | - | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0 | |
60 | + | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0)), SEP) | |
64 | 61 | let newMinedAmt = (parseIntValue(nodeRewardsArray[1]) + minedAmt) | |
65 | 62 | let newBeneficiaryAmt = (parseIntValue(nodeRewardsArray[2]) + beneficiaryAmt) | |
66 | 63 | let newProtocolAmt = (parseIntValue(nodeRewardsArray[3]) + protocolAmt) | |
67 | - | let newProtocolAmtPart1 = (parseIntValue(nodeRewardsArray[4]) + protocolAmtPart1) | |
68 | - | let newProtocolAmtPart2 = (parseIntValue(nodeRewardsArray[5]) + protocolAmtPart2) | |
69 | - | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt, newProtocolAmtPart1, newProtocolAmtPart2)) | |
64 | + | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt)) | |
70 | 65 | } | |
71 | 66 | ||
72 | 67 | ||
73 | 68 | @Callable(i) | |
74 | - | func constructor (anoteAddressStr | |
69 | + | func constructor (anoteAddressStr,protocolPartX6,benificaryPartX6) = if ((i.caller != this)) | |
75 | 70 | then throw("permissions denied") | |
76 | 71 | else if ((0 > protocolPartX6)) | |
77 | 72 | then throw("protocolPartX6 less then zero") | |
78 | 73 | else if ((0 > benificaryPartX6)) | |
79 | 74 | then throw("benificaryPartX6 less then zero") | |
80 | 75 | else if (((protocolPartX6 + benificaryPartX6) != MULT6)) | |
81 | 76 | then throw("parts sum must be 1") | |
82 | - | else [StringEntry(keyAnoteAddressStr(), validateAddressOrFail(anoteAddressStr)), | |
77 | + | else [StringEntry(keyAnoteAddressStr(), validateAddressOrFail(anoteAddressStr)), IntegerEntry(keyProtocolPartX6(), protocolPartX6), IntegerEntry(keyBenificaryPartX6(), benificaryPartX6)] | |
83 | 78 | ||
84 | 79 | ||
85 | 80 | ||
86 | 81 | @Callable(i) | |
87 | 82 | func distributeMinerReward (benificaryAddressStr) = if ((size(i.payments) != 1)) | |
88 | 83 | then throw("exact 1 payment must be attached") | |
89 | 84 | else if ((i.caller != i.originCaller)) | |
90 | 85 | then throw("dapp to dapp calls are not allowed") | |
91 | 86 | else { | |
92 | 87 | let pmt = i.payments[0] | |
93 | 88 | let minedAmt = pmt.amount | |
94 | 89 | let pmtAssetId = valueOrElse(pmt.assetId, ANOTEID) | |
95 | 90 | let feeAmt = i.fee | |
96 | 91 | let feeAssetId = valueOrElse(i.feeAssetId, ANOTEID) | |
97 | 92 | if ((pmtAssetId != ANOTEID)) | |
98 | 93 | then throw("only Waves can be used in payment") | |
99 | 94 | else if ((feeAssetId != ANOTEID)) | |
100 | 95 | then throw("only Waves can be used in fees") | |
101 | 96 | else if ((feeAmt != ((5 * MULT8) / 1000))) | |
102 | 97 | then throw("fee amount couldn't exceed 0.005") | |
103 | 98 | else { | |
104 | 99 | let anoteAddress = getAddressOrFail(keyAnoteAddressStr()) | |
105 | - | let masterNodeAddress = getAddressOrFail(keyMasterNodeAddressStr()) | |
106 | 100 | let minerAddress = i.caller | |
107 | 101 | let benificaryAddress = addressFromStringValue(benificaryAddressStr) | |
108 | 102 | let protocolPart = getIntOrFail(keyProtocolPartX6()) | |
109 | 103 | let benificaryPart = getIntOrFail(keyBenificaryPartX6()) | |
110 | 104 | let availableBalance = (wavesBalance(minerAddress).available - feeAmt) | |
111 | 105 | if ((availableBalance != 0)) | |
112 | 106 | then throw((("all " + toString(availableBalance)) + " Wavelets from the Node balance must be attached into the payment")) | |
113 | 107 | else { | |
114 | 108 | let benificaryAmt = fraction(minedAmt, benificaryPart, MULT6) | |
115 | 109 | let protocolAmt = (minedAmt - benificaryAmt) | |
116 | - | let protocolAmt1 = (protocolAmt / 2) | |
117 | - | let protocolAmt2 = (protocolAmt - protocolAmt1) | |
118 | - | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(anoteAddress, protocolAmt1, unit), ScriptTransfer(masterNodeAddress, protocolAmt2, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2)] | |
110 | + | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(anoteAddress, protocolAmt, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt)] | |
119 | 111 | } | |
120 | 112 | } | |
121 | 113 | } | |
122 | 114 | ||
123 | 115 |
github/deemru/w8io/026f985 42.90 ms ◑