tx · C8NemZ5XLGJj7veDY9SM73zcgvZaDPwxdJ8uCmRMvVtx 3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H: -0.01000000 Waves 2022.10.27 01:53 [2290017] smart account 3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H > SELF 0.00000000 Waves
{ "type": 13, "id": "C8NemZ5XLGJj7veDY9SM73zcgvZaDPwxdJ8uCmRMvVtx", "fee": 1000000, "feeAssetId": null, "timestamp": 1666824804149, "version": 2, "chainId": 84, "sender": "3N3Aq1GcHD8bZMGyVgyvaTHrBM7EySFtJ1H", "senderPublicKey": "69Rez9g3wdeHPiCsmjaaaK1GBhFjL79pxMPX9Fpk8S5e", "proofs": [ "3ow6MTT53yW9jLuXAmfmT7yfamXvrt7cX6rfQxAE2u4cgsaUhbYCtdyA7bYp6hrAhnD3Xz3Pk2JUwXmStkk9Ycg" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAwAAAAADU0VQAgAAAAJfXwAAAAAKQU5PVEVJRFNUUgIAAAAFV0FWRVMAAAAAB0FOT1RFSUQJAAJZAAAAAQUAAAAKQU5PVEVJRFNUUgAAAAEAAAABaQEAAAADYmlkAAAAAAQAAAAFYWRLZXkJAAEsAAAAAgIAAAAEJXNfXwkABCUAAAABCAUAAAABaQAAAAZjYWxsZXIEAAAAA3BtdAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAQAAAAKcG10QXNzZXRJZAkBAAAAC3ZhbHVlT3JFbHNlAAAAAggFAAAAA3BtdAAAAAdhc3NldElkBQAAAAdBTk9URUlEAwkBAAAAAiE9AAAAAgkAAZAAAAABCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAQkAAAIAAAABAgAAACBleGFjdCAxIHBheW1lbnQgbXVzdCBiZSBhdHRhY2hlZAMJAQAAAAIhPQAAAAIFAAAACnBtdEFzc2V0SWQFAAAAB0FOT1RFSUQJAAACAAAAAQIAAAAib25seSBBbm90ZXMgY2FuIGJlIHVzZWQgaW4gcGF5bWVudAQAAAALYWxyZWFkeVBhaWQJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQfAAAAAQUAAAAFYWRLZXkAAAAAAAAAAAAEAAAABmFtb3VudAkAAGQAAAACBQAAAAthbHJlYWR5UGFpZAgJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAAAAAGYW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAVhZEtleQUAAAAGYW1vdW50BQAAAANuaWwAAAAAzB4Spw==", "height": 2290017, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DWa4KnKpUWXYeqYHMYHAt9ZBDWt28JvraDQLJjjPt279 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | 6 | let ANOTEIDSTR = "WAVES" | |
9 | 7 | ||
10 | 8 | let ANOTEID = fromBase58String(ANOTEIDSTR) | |
11 | 9 | ||
12 | - | let ANOTEADDR = Address(base58'3N8EvpGmkantoqYAdiG4W7brYEJqzkQVRBA') | |
13 | - | ||
14 | - | let PROTOPARTX8 = 95000000 | |
15 | - | ||
16 | - | let BENPARTX8 = 5000000 | |
17 | - | ||
18 | - | func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal) | |
19 | - | ||
20 | - | ||
21 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("Mandatory this." + key) + " is not defined")) | |
22 | - | ||
23 | - | ||
24 | - | func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStringOrFail(key)), (("Fail to convert this." + key) + " value into Address")) | |
25 | - | ||
26 | - | ||
27 | - | func validateAddressOrFail (addressStr) = { | |
28 | - | let address = valueOrErrorMessage(addressFromString(addressStr), ("fail to convert into address " + addressStr)) | |
29 | - | if ((0 > wavesBalance(address).available)) | |
30 | - | then throw() | |
31 | - | else addressStr | |
10 | + | @Callable(i) | |
11 | + | func bid () = { | |
12 | + | let adKey = ("%s__" + toString(i.caller)) | |
13 | + | let pmt = i.payments[0] | |
14 | + | let pmtAssetId = valueOrElse(pmt.assetId, ANOTEID) | |
15 | + | if ((size(i.payments) != 1)) | |
16 | + | then throw("exact 1 payment must be attached") | |
17 | + | else if ((pmtAssetId != ANOTEID)) | |
18 | + | then throw("only Anotes can be used in payment") | |
19 | + | else { | |
20 | + | let alreadyPaid = valueOrElse(getInteger(adKey), 0) | |
21 | + | let amount = (alreadyPaid + i.payments[0].amount) | |
22 | + | [IntegerEntry(adKey, amount)] | |
23 | + | } | |
32 | 24 | } | |
33 | - | ||
34 | - | ||
35 | - | func keyNodeRewardsTotals (address) = ("%s%s__totals__" + address) | |
36 | - | ||
37 | - | ||
38 | - | func keyRewardHistory (nodeAddress,txId) = makeString(["%s%s%s", "history", toString(nodeAddress), toBase58String(txId)], SEP) | |
39 | - | ||
40 | - | ||
41 | - | 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) | |
42 | - | ||
43 | - | ||
44 | - | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt) = StringEntry(keyRewardHistory(nodeAddress, txId), dataRewardHistory(minedAmt, beneficiaryAmt, protocolAmt)) | |
45 | - | ||
46 | - | ||
47 | - | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d", toString(minedAmt), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
48 | - | ||
49 | - | ||
50 | - | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt) = { | |
51 | - | let nodeRewardsTotalsKEY = keyNodeRewardsTotals(toString(miner)) | |
52 | - | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0)), SEP) | |
53 | - | let newMinedAmt = (parseIntValue(nodeRewardsArray[1]) + minedAmt) | |
54 | - | let newBeneficiaryAmt = (parseIntValue(nodeRewardsArray[2]) + beneficiaryAmt) | |
55 | - | let newProtocolAmt = (parseIntValue(nodeRewardsArray[3]) + protocolAmt) | |
56 | - | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt)) | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | @Callable(i) | |
61 | - | func distributeMinerReward (benificaryAddressStr) = if ((size(i.payments) != 1)) | |
62 | - | then throw("exact 1 payment must be attached") | |
63 | - | else if ((i.caller != i.originCaller)) | |
64 | - | then throw("dapp to dapp calls are not allowed") | |
65 | - | else { | |
66 | - | let pmt = i.payments[0] | |
67 | - | let minedAmt = pmt.amount | |
68 | - | let pmtAssetId = valueOrElse(pmt.assetId, ANOTEID) | |
69 | - | let feeAmt = i.fee | |
70 | - | let feeAssetId = valueOrElse(i.feeAssetId, ANOTEID) | |
71 | - | if ((pmtAssetId != ANOTEID)) | |
72 | - | then throw("only Waves can be used in payment") | |
73 | - | else if ((feeAssetId != ANOTEID)) | |
74 | - | then throw("only Waves can be used in fees") | |
75 | - | else if ((feeAmt != ((5 * MULT8) / 1000))) | |
76 | - | then throw("fee amount couldn't exceed 0.005") | |
77 | - | else { | |
78 | - | let minerAddress = i.caller | |
79 | - | let benificaryAddress = addressFromStringValue(benificaryAddressStr) | |
80 | - | let protocolPart = PROTOPARTX8 | |
81 | - | let benificaryPart = BENPARTX8 | |
82 | - | let availableBalance = (wavesBalance(minerAddress).available - feeAmt) | |
83 | - | if ((availableBalance != 0)) | |
84 | - | then throw((("all " + toString(availableBalance)) + " Wavelets from the Node balance must be attached into the payment")) | |
85 | - | else { | |
86 | - | let benificaryAmt = fraction(minedAmt, benificaryPart, MULT8) | |
87 | - | let protocolAmt = (minedAmt - benificaryAmt) | |
88 | - | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(ANOTEADDR, protocolAmt, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt)] | |
89 | - | } | |
90 | - | } | |
91 | - | } | |
92 | 25 | ||
93 | 26 |
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 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | 6 | let ANOTEIDSTR = "WAVES" | |
9 | 7 | ||
10 | 8 | let ANOTEID = fromBase58String(ANOTEIDSTR) | |
11 | 9 | ||
12 | - | let ANOTEADDR = Address(base58'3N8EvpGmkantoqYAdiG4W7brYEJqzkQVRBA') | |
13 | - | ||
14 | - | let PROTOPARTX8 = 95000000 | |
15 | - | ||
16 | - | let BENPARTX8 = 5000000 | |
17 | - | ||
18 | - | func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal) | |
19 | - | ||
20 | - | ||
21 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("Mandatory this." + key) + " is not defined")) | |
22 | - | ||
23 | - | ||
24 | - | func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStringOrFail(key)), (("Fail to convert this." + key) + " value into Address")) | |
25 | - | ||
26 | - | ||
27 | - | func validateAddressOrFail (addressStr) = { | |
28 | - | let address = valueOrErrorMessage(addressFromString(addressStr), ("fail to convert into address " + addressStr)) | |
29 | - | if ((0 > wavesBalance(address).available)) | |
30 | - | then throw() | |
31 | - | else addressStr | |
10 | + | @Callable(i) | |
11 | + | func bid () = { | |
12 | + | let adKey = ("%s__" + toString(i.caller)) | |
13 | + | let pmt = i.payments[0] | |
14 | + | let pmtAssetId = valueOrElse(pmt.assetId, ANOTEID) | |
15 | + | if ((size(i.payments) != 1)) | |
16 | + | then throw("exact 1 payment must be attached") | |
17 | + | else if ((pmtAssetId != ANOTEID)) | |
18 | + | then throw("only Anotes can be used in payment") | |
19 | + | else { | |
20 | + | let alreadyPaid = valueOrElse(getInteger(adKey), 0) | |
21 | + | let amount = (alreadyPaid + i.payments[0].amount) | |
22 | + | [IntegerEntry(adKey, amount)] | |
23 | + | } | |
32 | 24 | } | |
33 | - | ||
34 | - | ||
35 | - | func keyNodeRewardsTotals (address) = ("%s%s__totals__" + address) | |
36 | - | ||
37 | - | ||
38 | - | func keyRewardHistory (nodeAddress,txId) = makeString(["%s%s%s", "history", toString(nodeAddress), toBase58String(txId)], SEP) | |
39 | - | ||
40 | - | ||
41 | - | 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) | |
42 | - | ||
43 | - | ||
44 | - | func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt) = StringEntry(keyRewardHistory(nodeAddress, txId), dataRewardHistory(minedAmt, beneficiaryAmt, protocolAmt)) | |
45 | - | ||
46 | - | ||
47 | - | func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt) = makeString(["%d%d%d%d%d", toString(minedAmt), toString(beneficiaryAmt), toString(protocolAmt)], SEP) | |
48 | - | ||
49 | - | ||
50 | - | func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt) = { | |
51 | - | let nodeRewardsTotalsKEY = keyNodeRewardsTotals(toString(miner)) | |
52 | - | let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0)), SEP) | |
53 | - | let newMinedAmt = (parseIntValue(nodeRewardsArray[1]) + minedAmt) | |
54 | - | let newBeneficiaryAmt = (parseIntValue(nodeRewardsArray[2]) + beneficiaryAmt) | |
55 | - | let newProtocolAmt = (parseIntValue(nodeRewardsArray[3]) + protocolAmt) | |
56 | - | StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt)) | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | @Callable(i) | |
61 | - | func distributeMinerReward (benificaryAddressStr) = if ((size(i.payments) != 1)) | |
62 | - | then throw("exact 1 payment must be attached") | |
63 | - | else if ((i.caller != i.originCaller)) | |
64 | - | then throw("dapp to dapp calls are not allowed") | |
65 | - | else { | |
66 | - | let pmt = i.payments[0] | |
67 | - | let minedAmt = pmt.amount | |
68 | - | let pmtAssetId = valueOrElse(pmt.assetId, ANOTEID) | |
69 | - | let feeAmt = i.fee | |
70 | - | let feeAssetId = valueOrElse(i.feeAssetId, ANOTEID) | |
71 | - | if ((pmtAssetId != ANOTEID)) | |
72 | - | then throw("only Waves can be used in payment") | |
73 | - | else if ((feeAssetId != ANOTEID)) | |
74 | - | then throw("only Waves can be used in fees") | |
75 | - | else if ((feeAmt != ((5 * MULT8) / 1000))) | |
76 | - | then throw("fee amount couldn't exceed 0.005") | |
77 | - | else { | |
78 | - | let minerAddress = i.caller | |
79 | - | let benificaryAddress = addressFromStringValue(benificaryAddressStr) | |
80 | - | let protocolPart = PROTOPARTX8 | |
81 | - | let benificaryPart = BENPARTX8 | |
82 | - | let availableBalance = (wavesBalance(minerAddress).available - feeAmt) | |
83 | - | if ((availableBalance != 0)) | |
84 | - | then throw((("all " + toString(availableBalance)) + " Wavelets from the Node balance must be attached into the payment")) | |
85 | - | else { | |
86 | - | let benificaryAmt = fraction(minedAmt, benificaryPart, MULT8) | |
87 | - | let protocolAmt = (minedAmt - benificaryAmt) | |
88 | - | [ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(ANOTEADDR, protocolAmt, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt)] | |
89 | - | } | |
90 | - | } | |
91 | - | } | |
92 | 25 | ||
93 | 26 |
github/deemru/w8io/026f985 32.62 ms ◑