tx · BD3QboVqFVkAacTHxVKbEAkTzomxZVMNENrHRKmLxVwm 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua: -0.01400000 Waves 2021.03.23 11:04 [1450127] smart account 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua > SELF 0.00000000 Waves
{ "type": 13, "id": "BD3QboVqFVkAacTHxVKbEAkTzomxZVMNENrHRKmLxVwm", "fee": 1400000, "feeAssetId": null, "timestamp": 1616486660192, "version": 2, "chainId": 84, "sender": "3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua", "senderPublicKey": "CTyHhnVTxf16Z4CmGGneAK8WB5g2QyT4MB8kUn8vPPcu", "proofs": [ "4D8ruisLnkcFTZvq9BpQqJZ4EL2CErzeUX5ebTe9uNsTaGcZ2BADtCAU6uPA9F9yV1GYM1dtZfHiqurMNEvqk8m2" ], "script": "base64:AAIEAAAAAAAAAAQIAhIAAAAAAAAAAAEAAAABaQEAAAAEY2FsbAAAAAAEAAAABWFzc2V0CQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAdhc3NldElkCQAEOAAAAAEFAAAABWFzc2V0CQAETAAAAAIJAQAAAAtCaW5hcnlFbnRyeQAAAAICAAAAA2JpbgEAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib29sBgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAADaW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAAA3N0cgIAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAECAAAAA3N0cgkABEwAAAACBQAAAAVhc3NldAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAB2Fzc2V0SWQAAAAAAAAAAAEHCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAHYXNzZXRJZAAAAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAB2Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5KOU8bg==", "height": 1450127, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2Ks8bwYNoDGiZtPW3zohi4gGxZLSy5qsQLq29Sk3RnV9 Next: DBizCVAQEPcn9iUentFkj6xoYhdbLsacen5ZwSBhR6m1 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let versionStakeContract = 1 | |
5 | - | ||
6 | - | let hcSeparator = "___" | |
7 | - | ||
8 | - | let hcWaves = "WAVES" | |
9 | - | ||
10 | - | let hcStakeContractName = "StakeContractNFT" | |
11 | - | ||
12 | - | let hcStakeReceiptName = "StakeReceiptNFT" | |
13 | - | ||
14 | - | let hcDecimalsDivisor = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000] | |
15 | - | ||
16 | - | let keydAppURL = "DAPP_URL" | |
17 | - | ||
18 | - | let keydAppName = "DAPP_NAME" | |
19 | - | ||
20 | - | let keyLockedQuantity = "LOCKED_QUANTITY_" | |
21 | - | ||
22 | - | let keyTokenTotalIssuedSupplies = "TOKEN_TOTAL_ISSUED_SUPPLIES" | |
23 | - | ||
24 | - | let keyTokenTotalBurnedSupplies = "TOKEN_TOTAL_BURNED_SUPPLIES" | |
25 | - | ||
26 | - | let keyAssetIssuedContracts = "ASSET_ISSUED_CONTRACTS_" | |
27 | - | ||
28 | - | let keyAssetBurnedContracts = "ASSET_BURNED_CONTRACTS_" | |
29 | - | ||
30 | - | let keyTotalIssuedContracts = "TOTAL_ISSUED_CONTRACTS" | |
31 | - | ||
32 | - | let keyTotalBurnedContracts = "TOTAL_BURNED_CONTRACTS" | |
33 | - | ||
34 | - | let keyNonce = "NONCE" | |
35 | - | ||
36 | - | let keyStakingWhitelist = "STAKING_WHITELIST" | |
37 | - | ||
38 | - | let tokenId = base58'7J7kaZgCXKkWFxjths5ZuMGsrkpxoawPBUGaFvzpHe7V' | |
39 | - | ||
40 | - | let tokenEligibilityPerBlock = (10 * 100000000) | |
41 | - | ||
42 | - | func getStringOrEmpty (key) = match getString(this, key) { | |
43 | - | case dataFound: String => | |
44 | - | dataFound | |
45 | - | case _ => | |
46 | - | "" | |
47 | - | } | |
48 | - | ||
49 | - | ||
50 | - | func getStringOrError (key) = match getString(this, key) { | |
51 | - | case dataFound: String => | |
52 | - | dataFound | |
53 | - | case _ => | |
54 | - | throw(("getStringOrError: " + key)) | |
55 | - | } | |
56 | - | ||
57 | - | ||
58 | - | func getIntegerOrZero (key) = match getInteger(this, key) { | |
59 | - | case dataFound: Int => | |
60 | - | dataFound | |
61 | - | case _ => | |
62 | - | 0 | |
63 | - | } | |
64 | - | ||
65 | - | ||
66 | - | func getNewNonce () = { | |
67 | - | let incrNonce = (getIntegerOrZero(keyNonce) + 1) | |
68 | - | [parseIntValue((toString(incrNonce) + toString(height))), incrNonce] | |
69 | - | } | |
70 | 4 | ||
71 | 5 | ||
72 | 6 | @Callable(i) | |
73 | - | func depositToStake () = if ((this == i.caller)) | |
74 | - | then throw("dApp can't interact with self") | |
75 | - | else if ((size(i.payments) != 1)) | |
76 | - | then throw("Not a valid amount of payments (require 1)") | |
77 | - | else if ((1 > i.payments[0].amount)) | |
78 | - | then throw("Can't stake negatif or zero") | |
79 | - | else { | |
80 | - | let assetId = match i.payments[0].assetId { | |
81 | - | case isAnAsset: ByteVector => | |
82 | - | toBase58String(isAnAsset) | |
83 | - | case _ => | |
84 | - | hcWaves | |
85 | - | } | |
86 | - | if ((contains(getStringOrError(keyStakingWhitelist), assetId) != true)) | |
87 | - | then throw("Asset not on staking whitelist") | |
88 | - | else { | |
89 | - | let nonce = getNewNonce() | |
90 | - | let contractDesc = ((((((((((((getStringOrError(keydAppName) + hcSeparator) + getStringOrError(keydAppURL)) + hcSeparator) + toString(versionStakeContract)) + hcSeparator) + toString(height)) + hcSeparator) + toBase58String(i.caller.bytes)) + hcSeparator) + assetId) + hcSeparator) + toString(i.payments[0].amount)) | |
91 | - | let contractIssue = Issue(hcStakeContractName, contractDesc, 1, 0, false, unit, nonce[0]) | |
92 | - | let contractId = calculateAssetId(contractIssue) | |
93 | - | let newLockedQuantity = (getIntegerOrZero((keyLockedQuantity + assetId)) + i.payments[0].amount) | |
94 | - | let newAssetIssuedContracts = (getIntegerOrZero((keyAssetIssuedContracts + assetId)) + 1) | |
95 | - | let newTotalIssuedContracts = (getIntegerOrZero(keyTotalIssuedContracts) + 1) | |
96 | - | [IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyLockedQuantity + assetId), newLockedQuantity), IntegerEntry((keyAssetIssuedContracts + assetId), newAssetIssuedContracts), IntegerEntry(keyTotalIssuedContracts, newTotalIssuedContracts), contractIssue, ScriptTransfer(i.caller, contractIssue.quantity, contractId)] | |
97 | - | } | |
98 | - | } | |
99 | - | ||
100 | - | ||
101 | - | ||
102 | - | @Callable(i) | |
103 | - | func withdrawStake () = if ((this == i.caller)) | |
104 | - | then throw("dApp can't interact with self") | |
105 | - | else if ((size(i.payments) != 1)) | |
106 | - | then throw("Not a valid amount of payments (require 1)") | |
107 | - | else if ((i.payments[0].amount != 1)) | |
108 | - | then throw("Can't stake negatif or zero") | |
109 | - | else { | |
110 | - | let assetId = match i.payments[0].assetId { | |
111 | - | case isByteVector: ByteVector => | |
112 | - | isByteVector | |
113 | - | case _ => | |
114 | - | throw("Not an Asset") | |
115 | - | } | |
116 | - | let contractInfo = match assetInfo(assetId) { | |
117 | - | case isAnAsset: Asset => | |
118 | - | isAnAsset | |
119 | - | case _ => | |
120 | - | throw("Couldn't find Asset") | |
121 | - | } | |
122 | - | if ((contractInfo.issuer != this)) | |
123 | - | then throw("Contract error: dApp isn't issuer") | |
124 | - | else if ((contractInfo.name != hcStakeContractName)) | |
125 | - | then throw("Contract error: name") | |
126 | - | else if (if (if (if ((contractInfo.decimals != 0)) | |
127 | - | then true | |
128 | - | else (contractInfo.quantity != 1)) | |
129 | - | then true | |
130 | - | else (contractInfo.reissuable != false)) | |
131 | - | then true | |
132 | - | else (contractInfo.scripted != false)) | |
133 | - | then throw("Contract error: specs") | |
134 | - | else { | |
135 | - | let contractDescArray = split(contractInfo.description, hcSeparator) | |
136 | - | let contractdAppName = contractDescArray[0] | |
137 | - | let contractdAppURL = contractDescArray[1] | |
138 | - | let contractVersion = parseIntValue(contractDescArray[2]) | |
139 | - | let contractStartingHeight = parseIntValue(contractDescArray[3]) | |
140 | - | let contractStakerId = contractDescArray[4] | |
141 | - | let contractAssetId = contractDescArray[5] | |
142 | - | let contractAssetInfo = match assetInfo(fromBase58String(contractDescArray[5])) { | |
143 | - | case isAnAsset: Asset => | |
144 | - | isAnAsset | |
145 | - | case _ => | |
146 | - | throw("Contract error: asset") | |
147 | - | } | |
148 | - | let contractAssetQuantity = parseIntValue(contractDescArray[6]) | |
149 | - | if ((size(contractDescArray) != 7)) | |
150 | - | then throw("Contract error: corrupted") | |
151 | - | else if ((contractVersion > versionStakeContract)) | |
152 | - | then throw("Contract error: version") | |
153 | - | else if ((contractStartingHeight >= height)) | |
154 | - | then throw("Contract error: starting height") | |
155 | - | else if (if ((1 > contractAssetQuantity)) | |
156 | - | then true | |
157 | - | else (contractAssetQuantity > contractAssetInfo.quantity)) | |
158 | - | then throw("Contract error: quantity") | |
159 | - | else if ((contractAssetQuantity > assetBalance(this, contractAssetInfo.id))) | |
160 | - | then throw("Contract error: dApp balance") | |
161 | - | else { | |
162 | - | let contractBlocksAway = (height - contractStartingHeight) | |
163 | - | let contractMaxEligible = (contractBlocksAway * tokenEligibilityPerBlock) | |
164 | - | let dAppCurrentAssetLockedQuantity = getIntegerValue(this, (keyLockedQuantity + contractAssetId)) | |
165 | - | let contractTokenQuantityToReceive = fraction(contractMaxEligible, contractAssetQuantity, dAppCurrentAssetLockedQuantity) | |
166 | - | let nonce = getNewNonce() | |
167 | - | let tokenInfo = match assetInfo(tokenId) { | |
168 | - | case isAnAsset: Asset => | |
169 | - | isAnAsset | |
170 | - | case _ => | |
171 | - | throw("Token not existing bro") | |
172 | - | } | |
173 | - | let r1 = (((((("dApp '" + contractdAppName) + " (") + contractdAppURL) + ") '. Contract version ") + toString(contractVersion)) + ". ") | |
174 | - | let r2 = (("Contract signer: " + contractStakerId) + ". ") | |
175 | - | let r3 = (((((("Asset and quantity locked: " + toString((contractAssetQuantity / hcDecimalsDivisor[contractAssetInfo.decimals]))) + " ") + contractAssetInfo.name) + " (id: ") + contractAssetId) + "). ") | |
176 | - | let r4 = (("Lock duration: " + toString(contractBlocksAway)) + " blocks. ") | |
177 | - | let r5 = (((((("Staked and received " + toString((contractTokenQuantityToReceive / hcDecimalsDivisor[tokenInfo.decimals]))) + " ") + tokenInfo.name) + " (id: ") + toBase58String(tokenId)) + ").") | |
178 | - | let receiptDesc = ((((r1 + r2) + r3) + r4) + r5) | |
179 | - | let receiptIssue = Issue(hcStakeReceiptName, receiptDesc, 1, 0, false, unit, nonce[0]) | |
180 | - | let receiptId = calculateAssetId(receiptIssue) | |
181 | - | let newLockedQuantity = (getIntegerValue(this, (keyLockedQuantity + contractAssetId)) - contractAssetQuantity) | |
182 | - | let newTotalIssuedSupplies = (getIntegerOrZero(keyTokenTotalIssuedSupplies) + contractTokenQuantityToReceive) | |
183 | - | let newAssetBurnedContracts = (getIntegerOrZero((keyAssetBurnedContracts + contractAssetId)) + 1) | |
184 | - | let newTotalBurnedContracts = (getIntegerOrZero(keyTotalBurnedContracts) + 1) | |
185 | - | if ((0 > newLockedQuantity)) | |
186 | - | then throw("Contract error: invalid quantity") | |
187 | - | else [Burn(assetId, 1), IntegerEntry((keyLockedQuantity + contractAssetId), newLockedQuantity), IntegerEntry(keyTokenTotalIssuedSupplies, newTotalIssuedSupplies), IntegerEntry((keyAssetBurnedContracts + contractAssetId), newAssetBurnedContracts), IntegerEntry(keyTotalBurnedContracts, newTotalBurnedContracts), receiptIssue, ScriptTransfer(i.caller, receiptIssue.quantity, receiptId), ScriptTransfer(i.caller, contractAssetQuantity, contractAssetInfo.id), Reissue(tokenId, contractTokenQuantityToReceive, true), ScriptTransfer(i.caller, contractTokenQuantityToReceive, tokenId)] | |
188 | - | } | |
189 | - | } | |
190 | - | } | |
7 | + | func call () = { | |
8 | + | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
9 | + | let assetId = calculateAssetId(asset) | |
10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
11 | + | } | |
191 | 12 | ||
192 | 13 | ||
193 | 14 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let versionStakeContract = 1 | |
5 | - | ||
6 | - | let hcSeparator = "___" | |
7 | - | ||
8 | - | let hcWaves = "WAVES" | |
9 | - | ||
10 | - | let hcStakeContractName = "StakeContractNFT" | |
11 | - | ||
12 | - | let hcStakeReceiptName = "StakeReceiptNFT" | |
13 | - | ||
14 | - | let hcDecimalsDivisor = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000] | |
15 | - | ||
16 | - | let keydAppURL = "DAPP_URL" | |
17 | - | ||
18 | - | let keydAppName = "DAPP_NAME" | |
19 | - | ||
20 | - | let keyLockedQuantity = "LOCKED_QUANTITY_" | |
21 | - | ||
22 | - | let keyTokenTotalIssuedSupplies = "TOKEN_TOTAL_ISSUED_SUPPLIES" | |
23 | - | ||
24 | - | let keyTokenTotalBurnedSupplies = "TOKEN_TOTAL_BURNED_SUPPLIES" | |
25 | - | ||
26 | - | let keyAssetIssuedContracts = "ASSET_ISSUED_CONTRACTS_" | |
27 | - | ||
28 | - | let keyAssetBurnedContracts = "ASSET_BURNED_CONTRACTS_" | |
29 | - | ||
30 | - | let keyTotalIssuedContracts = "TOTAL_ISSUED_CONTRACTS" | |
31 | - | ||
32 | - | let keyTotalBurnedContracts = "TOTAL_BURNED_CONTRACTS" | |
33 | - | ||
34 | - | let keyNonce = "NONCE" | |
35 | - | ||
36 | - | let keyStakingWhitelist = "STAKING_WHITELIST" | |
37 | - | ||
38 | - | let tokenId = base58'7J7kaZgCXKkWFxjths5ZuMGsrkpxoawPBUGaFvzpHe7V' | |
39 | - | ||
40 | - | let tokenEligibilityPerBlock = (10 * 100000000) | |
41 | - | ||
42 | - | func getStringOrEmpty (key) = match getString(this, key) { | |
43 | - | case dataFound: String => | |
44 | - | dataFound | |
45 | - | case _ => | |
46 | - | "" | |
47 | - | } | |
48 | - | ||
49 | - | ||
50 | - | func getStringOrError (key) = match getString(this, key) { | |
51 | - | case dataFound: String => | |
52 | - | dataFound | |
53 | - | case _ => | |
54 | - | throw(("getStringOrError: " + key)) | |
55 | - | } | |
56 | - | ||
57 | - | ||
58 | - | func getIntegerOrZero (key) = match getInteger(this, key) { | |
59 | - | case dataFound: Int => | |
60 | - | dataFound | |
61 | - | case _ => | |
62 | - | 0 | |
63 | - | } | |
64 | - | ||
65 | - | ||
66 | - | func getNewNonce () = { | |
67 | - | let incrNonce = (getIntegerOrZero(keyNonce) + 1) | |
68 | - | [parseIntValue((toString(incrNonce) + toString(height))), incrNonce] | |
69 | - | } | |
70 | 4 | ||
71 | 5 | ||
72 | 6 | @Callable(i) | |
73 | - | func depositToStake () = if ((this == i.caller)) | |
74 | - | then throw("dApp can't interact with self") | |
75 | - | else if ((size(i.payments) != 1)) | |
76 | - | then throw("Not a valid amount of payments (require 1)") | |
77 | - | else if ((1 > i.payments[0].amount)) | |
78 | - | then throw("Can't stake negatif or zero") | |
79 | - | else { | |
80 | - | let assetId = match i.payments[0].assetId { | |
81 | - | case isAnAsset: ByteVector => | |
82 | - | toBase58String(isAnAsset) | |
83 | - | case _ => | |
84 | - | hcWaves | |
85 | - | } | |
86 | - | if ((contains(getStringOrError(keyStakingWhitelist), assetId) != true)) | |
87 | - | then throw("Asset not on staking whitelist") | |
88 | - | else { | |
89 | - | let nonce = getNewNonce() | |
90 | - | let contractDesc = ((((((((((((getStringOrError(keydAppName) + hcSeparator) + getStringOrError(keydAppURL)) + hcSeparator) + toString(versionStakeContract)) + hcSeparator) + toString(height)) + hcSeparator) + toBase58String(i.caller.bytes)) + hcSeparator) + assetId) + hcSeparator) + toString(i.payments[0].amount)) | |
91 | - | let contractIssue = Issue(hcStakeContractName, contractDesc, 1, 0, false, unit, nonce[0]) | |
92 | - | let contractId = calculateAssetId(contractIssue) | |
93 | - | let newLockedQuantity = (getIntegerOrZero((keyLockedQuantity + assetId)) + i.payments[0].amount) | |
94 | - | let newAssetIssuedContracts = (getIntegerOrZero((keyAssetIssuedContracts + assetId)) + 1) | |
95 | - | let newTotalIssuedContracts = (getIntegerOrZero(keyTotalIssuedContracts) + 1) | |
96 | - | [IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyLockedQuantity + assetId), newLockedQuantity), IntegerEntry((keyAssetIssuedContracts + assetId), newAssetIssuedContracts), IntegerEntry(keyTotalIssuedContracts, newTotalIssuedContracts), contractIssue, ScriptTransfer(i.caller, contractIssue.quantity, contractId)] | |
97 | - | } | |
98 | - | } | |
99 | - | ||
100 | - | ||
101 | - | ||
102 | - | @Callable(i) | |
103 | - | func withdrawStake () = if ((this == i.caller)) | |
104 | - | then throw("dApp can't interact with self") | |
105 | - | else if ((size(i.payments) != 1)) | |
106 | - | then throw("Not a valid amount of payments (require 1)") | |
107 | - | else if ((i.payments[0].amount != 1)) | |
108 | - | then throw("Can't stake negatif or zero") | |
109 | - | else { | |
110 | - | let assetId = match i.payments[0].assetId { | |
111 | - | case isByteVector: ByteVector => | |
112 | - | isByteVector | |
113 | - | case _ => | |
114 | - | throw("Not an Asset") | |
115 | - | } | |
116 | - | let contractInfo = match assetInfo(assetId) { | |
117 | - | case isAnAsset: Asset => | |
118 | - | isAnAsset | |
119 | - | case _ => | |
120 | - | throw("Couldn't find Asset") | |
121 | - | } | |
122 | - | if ((contractInfo.issuer != this)) | |
123 | - | then throw("Contract error: dApp isn't issuer") | |
124 | - | else if ((contractInfo.name != hcStakeContractName)) | |
125 | - | then throw("Contract error: name") | |
126 | - | else if (if (if (if ((contractInfo.decimals != 0)) | |
127 | - | then true | |
128 | - | else (contractInfo.quantity != 1)) | |
129 | - | then true | |
130 | - | else (contractInfo.reissuable != false)) | |
131 | - | then true | |
132 | - | else (contractInfo.scripted != false)) | |
133 | - | then throw("Contract error: specs") | |
134 | - | else { | |
135 | - | let contractDescArray = split(contractInfo.description, hcSeparator) | |
136 | - | let contractdAppName = contractDescArray[0] | |
137 | - | let contractdAppURL = contractDescArray[1] | |
138 | - | let contractVersion = parseIntValue(contractDescArray[2]) | |
139 | - | let contractStartingHeight = parseIntValue(contractDescArray[3]) | |
140 | - | let contractStakerId = contractDescArray[4] | |
141 | - | let contractAssetId = contractDescArray[5] | |
142 | - | let contractAssetInfo = match assetInfo(fromBase58String(contractDescArray[5])) { | |
143 | - | case isAnAsset: Asset => | |
144 | - | isAnAsset | |
145 | - | case _ => | |
146 | - | throw("Contract error: asset") | |
147 | - | } | |
148 | - | let contractAssetQuantity = parseIntValue(contractDescArray[6]) | |
149 | - | if ((size(contractDescArray) != 7)) | |
150 | - | then throw("Contract error: corrupted") | |
151 | - | else if ((contractVersion > versionStakeContract)) | |
152 | - | then throw("Contract error: version") | |
153 | - | else if ((contractStartingHeight >= height)) | |
154 | - | then throw("Contract error: starting height") | |
155 | - | else if (if ((1 > contractAssetQuantity)) | |
156 | - | then true | |
157 | - | else (contractAssetQuantity > contractAssetInfo.quantity)) | |
158 | - | then throw("Contract error: quantity") | |
159 | - | else if ((contractAssetQuantity > assetBalance(this, contractAssetInfo.id))) | |
160 | - | then throw("Contract error: dApp balance") | |
161 | - | else { | |
162 | - | let contractBlocksAway = (height - contractStartingHeight) | |
163 | - | let contractMaxEligible = (contractBlocksAway * tokenEligibilityPerBlock) | |
164 | - | let dAppCurrentAssetLockedQuantity = getIntegerValue(this, (keyLockedQuantity + contractAssetId)) | |
165 | - | let contractTokenQuantityToReceive = fraction(contractMaxEligible, contractAssetQuantity, dAppCurrentAssetLockedQuantity) | |
166 | - | let nonce = getNewNonce() | |
167 | - | let tokenInfo = match assetInfo(tokenId) { | |
168 | - | case isAnAsset: Asset => | |
169 | - | isAnAsset | |
170 | - | case _ => | |
171 | - | throw("Token not existing bro") | |
172 | - | } | |
173 | - | let r1 = (((((("dApp '" + contractdAppName) + " (") + contractdAppURL) + ") '. Contract version ") + toString(contractVersion)) + ". ") | |
174 | - | let r2 = (("Contract signer: " + contractStakerId) + ". ") | |
175 | - | let r3 = (((((("Asset and quantity locked: " + toString((contractAssetQuantity / hcDecimalsDivisor[contractAssetInfo.decimals]))) + " ") + contractAssetInfo.name) + " (id: ") + contractAssetId) + "). ") | |
176 | - | let r4 = (("Lock duration: " + toString(contractBlocksAway)) + " blocks. ") | |
177 | - | let r5 = (((((("Staked and received " + toString((contractTokenQuantityToReceive / hcDecimalsDivisor[tokenInfo.decimals]))) + " ") + tokenInfo.name) + " (id: ") + toBase58String(tokenId)) + ").") | |
178 | - | let receiptDesc = ((((r1 + r2) + r3) + r4) + r5) | |
179 | - | let receiptIssue = Issue(hcStakeReceiptName, receiptDesc, 1, 0, false, unit, nonce[0]) | |
180 | - | let receiptId = calculateAssetId(receiptIssue) | |
181 | - | let newLockedQuantity = (getIntegerValue(this, (keyLockedQuantity + contractAssetId)) - contractAssetQuantity) | |
182 | - | let newTotalIssuedSupplies = (getIntegerOrZero(keyTokenTotalIssuedSupplies) + contractTokenQuantityToReceive) | |
183 | - | let newAssetBurnedContracts = (getIntegerOrZero((keyAssetBurnedContracts + contractAssetId)) + 1) | |
184 | - | let newTotalBurnedContracts = (getIntegerOrZero(keyTotalBurnedContracts) + 1) | |
185 | - | if ((0 > newLockedQuantity)) | |
186 | - | then throw("Contract error: invalid quantity") | |
187 | - | else [Burn(assetId, 1), IntegerEntry((keyLockedQuantity + contractAssetId), newLockedQuantity), IntegerEntry(keyTokenTotalIssuedSupplies, newTotalIssuedSupplies), IntegerEntry((keyAssetBurnedContracts + contractAssetId), newAssetBurnedContracts), IntegerEntry(keyTotalBurnedContracts, newTotalBurnedContracts), receiptIssue, ScriptTransfer(i.caller, receiptIssue.quantity, receiptId), ScriptTransfer(i.caller, contractAssetQuantity, contractAssetInfo.id), Reissue(tokenId, contractTokenQuantityToReceive, true), ScriptTransfer(i.caller, contractTokenQuantityToReceive, tokenId)] | |
188 | - | } | |
189 | - | } | |
190 | - | } | |
7 | + | func call () = { | |
8 | + | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
9 | + | let assetId = calculateAssetId(asset) | |
10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
11 | + | } | |
191 | 12 | ||
192 | 13 | ||
193 | 14 | @Verifier(tx) | |
194 | 15 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
195 | 16 |
github/deemru/w8io/169f3d6 60.79 ms ◑