tx · 6Tzz65bbwxtk3z2pDqNogbiC4CRubyok3eFHDo5ZaBkN

3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua:  -0.01400000 Waves

2021.03.22 18:58 [1449163] smart account 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua > SELF 0.00000000 Waves

{ "type": 13, "id": "6Tzz65bbwxtk3z2pDqNogbiC4CRubyok3eFHDo5ZaBkN", "fee": 1400000, "feeAssetId": null, "timestamp": 1616428754716, "version": 2, "chainId": 84, "sender": "3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua", "senderPublicKey": "CTyHhnVTxf16Z4CmGGneAK8WB5g2QyT4MB8kUn8vPPcu", "proofs": [ "2Z2gcjqdGSBpgijDcjbtwkDMrVhBYNeX17qVgjcTmnpvYgzXJLtaDpTr4ujh4ryfsv4TbiNBC8P9mq6abZ1P8hnw" ], "script": "base64:AAIEAAAAAAAAAAQIAhIAAAAAAAAAAAEAAAABaQEAAAAEY2FsbAAAAAAEAAAABWFzc2V0CQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAdhc3NldElkCQAEOAAAAAEFAAAABWFzc2V0CQAETAAAAAIJAQAAAAtCaW5hcnlFbnRyeQAAAAICAAAAA2JpbgEAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib29sBgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAADaW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAAA3N0cgIAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAECAAAAA3N0cgkABEwAAAACBQAAAAVhc3NldAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAB2Fzc2V0SWQAAAAAAAAAAAEHCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAHYXNzZXRJZAAAAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAB2Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5KOU8bg==", "height": 1449163, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BAGnj6tmuFk7V2GezpzPk5gudk6mfu5WitAtwC1cC6x1 Next: 2Ks8bwYNoDGiZtPW3zohi4gGxZLSy5qsQLq29Sk3RnV9 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let versionStakeContract = 1
5-
6-let hcSeparator = "___"
7-
8-let hcWaves = "WAVES"
9-
10-let keydAppURL = "DAPP_URL"
11-
12-let keydAppName = "DAPP_NAME"
13-
14-let keyStakingWhitelist = "STAKING_WHITELIST"
15-
16-let keyNonce = "NONCE"
17-
18-let keyStakeContractName = "StakeContractNFT"
19-
20-let keyStakeReceiptName = "StakeReceiptNFT"
21-
22-let keyLockedAmount = "LOCKED_AMOUNT_"
23-
24-let keyTokenCirculatingSupplies = "TOKEN_CIRCULATING_SUPPLIES"
25-
26-let keyTokenTotalIssuedSupplies = "TOKEN_TOTAL_ISSUED_SUPPLIES"
27-
28-let keyTokenTotalBurnedSupplies = "TOKEN_TOTAL_BURNED_SUPPLIES"
29-
30-let keyAssetOngoingContracts = "ASSET_ONGOING_CONTRACTS_"
31-
32-let keyAssetIssuedContracts = "ASSET_ISSUED_CONTRACTS_"
33-
34-let keyAssetBurnedContracts = "ASSET_BURNED_CONTRACTS_"
35-
36-let keyTotalOngoingContracts = "TOTAL_ONGOING_CONTRACTS"
37-
38-let keyTotalIssuedContracts = "TOTAL_ISSUED_CONTRACTS"
39-
40-let keyTotalBurnedContracts = "TOTAL_BURNED_CONTRACTS"
41-
42-let tokenId = base58'7J7kaZgCXKkWFxjths5ZuMGsrkpxoawPBUGaFvzpHe7V'
43-
44-let tokenEligibilityPerBlock = (10 * 100000000)
45-
46-func getStringOrEmpty (key) = match getString(this, key) {
47- case dataFound: String =>
48- dataFound
49- case _ =>
50- ""
51-}
52-
53-
54-func getIntegerOrZero (key) = match getInteger(this, key) {
55- case isAnInteger: Int =>
56- isAnInteger
57- case _ =>
58- 0
59-}
60-
61-
62-func getNewNonce () = {
63- let incrNonce = (getIntegerOrZero(keyNonce) + 1)
64-[parseIntValue((toString(incrNonce) + toString(height))), incrNonce]
65- }
664
675
686 @Callable(i)
69-func depositToStake () = if ((this == i.caller))
70- then throw("dApp can't interact with self")
71- else if ((size(i.payments) != 1))
72- then throw("Not a valid amount of payments (require 1)")
73- else if ((1 > i.payments[0].amount))
74- then throw("Can't stake negatif or zero")
75- else {
76- let assetId = match i.payments[0].assetId {
77- case isAnAsset: ByteVector =>
78- toBase58String(isAnAsset)
79- case _ =>
80- hcWaves
81- }
82- if ((contains(getStringOrEmpty(keyStakingWhitelist), assetId) != true))
83- then throw("Asset not on staking whitelist")
84- else {
85- let nonce = getNewNonce()
86- let contractDesc = ((((((((toString(versionStakeContract) + hcSeparator) + toString(height)) + hcSeparator) + toBase58String(i.caller.bytes)) + hcSeparator) + assetId) + hcSeparator) + toString(i.payments[0].amount))
87- let contractIssue = Issue(keyStakeContractName, contractDesc, 1, 0, false, unit, nonce[0])
88- let contractId = calculateAssetId(contractIssue)
89- let newLockedAmount = (getIntegerOrZero((keyLockedAmount + assetId)) + i.payments[0].amount)
90- let newAssetOngoingContracts = (getIntegerOrZero((keyAssetOngoingContracts + assetId)) + 1)
91- let newAssetIssuedContracts = (getIntegerOrZero((keyAssetIssuedContracts + assetId)) + 1)
92- let newTotalOngoingContracts = (getIntegerOrZero(keyTotalOngoingContracts) + 1)
93- let newTotalIssuedContracts = (getIntegerOrZero(keyTotalIssuedContracts) + 1)
94-[IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyLockedAmount + assetId), newLockedAmount), IntegerEntry((keyAssetOngoingContracts + assetId), newAssetOngoingContracts), IntegerEntry((keyAssetIssuedContracts + assetId), newAssetIssuedContracts), IntegerEntry(keyTotalOngoingContracts, newTotalOngoingContracts), IntegerEntry(keyTotalIssuedContracts, newTotalIssuedContracts), contractIssue, ScriptTransfer(i.caller, contractIssue.quantity, contractId)]
95- }
96- }
97-
98-
99-
100-@Callable(i)
101-func withdrawStake () = if ((this == i.caller))
102- then throw("dApp can't interact with self")
103- else if ((size(i.payments) != 1))
104- then throw("Not a valid amount of payments (require 1)")
105- else if ((1 > i.payments[0].amount))
106- then throw("Can't stake negatif or zero")
107- else {
108- let assetId = match i.payments[0].assetId {
109- case isByteVector: ByteVector =>
110- isByteVector
111- case _ =>
112- throw("Not an Asset")
113- }
114- let contractInfo = match assetInfo(assetId) {
115- case isAnAsset: Asset =>
116- isAnAsset
117- case _ =>
118- throw("Couldn't find Asset")
119- }
120- if (if (if (if (if ((contractInfo.issuer != this))
121- then true
122- else (contractInfo.decimals != 0))
123- then true
124- else (contractInfo.quantity != 1))
125- then true
126- else (contractInfo.reissuable != false))
127- then true
128- else (contractInfo.name != keyStakeContractName))
129- then throw("Not a Contract")
130- else {
131- let contractDescArray = split(contractInfo.description, hcSeparator)
132- let contractVersion = parseIntValue(contractDescArray[0])
133- let contractStartingHeight = parseIntValue(contractDescArray[1])
134- let contractStakerId = contractDescArray[2]
135- let contractAsset = match assetInfo(fromBase58String(contractDescArray[3])) {
136- case isAnAsset: Asset =>
137- isAnAsset
138- case _ =>
139- throw("Contract error: asset")
140- }
141- let contractAssetAmount = parseIntValue(contractDescArray[4])
142- if ((size(contractDescArray) != 5))
143- then throw("Contract error: corrupted")
144- else if ((contractVersion > versionStakeContract))
145- then throw("Contract error: version")
146- else if ((contractStartingHeight >= height))
147- then throw("Contract error: starting height")
148- else if (if ((1 > contractAssetAmount))
149- then true
150- else (contractAssetAmount > contractAsset.quantity))
151- then throw("Contract error: quantity")
152- else if ((contractAssetAmount > assetBalance(this, contractAsset.id)))
153- then throw("Contract error: dApp balance")
154- else {
155- let assetIdString = toBase58String(contractAsset.id)
156- let blocksAway = (height - contractStartingHeight)
157- let userTokenEligibility = (blocksAway * tokenEligibilityPerBlock)
158- let currentAssetLockedAmount = getIntegerValue(this, (keyLockedAmount + contractDescArray[3]))
159- let userTokenAmountToReceive = fraction(userTokenEligibility, contractAssetAmount, currentAssetLockedAmount)
160- let nonce = getNewNonce()
161- let tokenInfo = match assetInfo(tokenId) {
162- case isAnAsset: Asset =>
163- isAnAsset
164- case _ =>
165- throw("Token not existing bro")
166- }
167- let receiptDesc = ((((((((((contractStakerId + " has locked ") + toString(contractAssetAmount)) + "
168- ") + contractAsset.name) + " during ") + toString(blocksAway)) + " blocks and received ") + toString(userTokenAmountToReceive)) + " ") + tokenInfo.name)
169- let receiptIssue = Issue(keyStakeReceiptName, receiptDesc, 1, 0, false, unit, nonce[0])
170- let receiptId = calculateAssetId(receiptIssue)
171- let newLockedAmount = (getIntegerValue(this, (keyLockedAmount + contractDescArray[3])) - contractAssetAmount)
172- let newCirculatingSupplies = (getIntegerOrZero(keyTokenCirculatingSupplies) + userTokenAmountToReceive)
173- let newTotalIssuedSupplies = (getIntegerOrZero(keyTokenTotalIssuedSupplies) + userTokenAmountToReceive)
174- let newAssetOngoingContracts = (getIntegerOrZero((keyAssetOngoingContracts + assetIdString)) - 1)
175- let newAssetBurnedContracts = (getIntegerOrZero((keyAssetBurnedContracts + assetIdString)) + 1)
176- let newTotalOngoingContracts = (getIntegerOrZero(keyTotalOngoingContracts) - 1)
177- let newTotalBurnedContracts = (getIntegerOrZero(keyTotalBurnedContracts) + 1)
178-[Burn(assetId, 1), IntegerEntry((keyLockedAmount + contractDescArray[3]), newLockedAmount), IntegerEntry(keyTokenCirculatingSupplies, newCirculatingSupplies), IntegerEntry(keyTokenTotalIssuedSupplies, newTotalIssuedSupplies), IntegerEntry((keyAssetOngoingContracts + assetIdString), newAssetOngoingContracts), IntegerEntry((keyAssetBurnedContracts + assetIdString), newAssetBurnedContracts), IntegerEntry(keyTotalOngoingContracts, newTotalOngoingContracts), IntegerEntry(keyTotalBurnedContracts, newTotalBurnedContracts), receiptIssue, ScriptTransfer(i.caller, receiptIssue.quantity, receiptId), ScriptTransfer(i.caller, contractAssetAmount, contractAsset.id), Reissue(tokenId, userTokenAmountToReceive, true), ScriptTransfer(i.caller, userTokenAmountToReceive, tokenId)]
179- }
180- }
181- }
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+ }
18212
18313
18414 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let versionStakeContract = 1
5-
6-let hcSeparator = "___"
7-
8-let hcWaves = "WAVES"
9-
10-let keydAppURL = "DAPP_URL"
11-
12-let keydAppName = "DAPP_NAME"
13-
14-let keyStakingWhitelist = "STAKING_WHITELIST"
15-
16-let keyNonce = "NONCE"
17-
18-let keyStakeContractName = "StakeContractNFT"
19-
20-let keyStakeReceiptName = "StakeReceiptNFT"
21-
22-let keyLockedAmount = "LOCKED_AMOUNT_"
23-
24-let keyTokenCirculatingSupplies = "TOKEN_CIRCULATING_SUPPLIES"
25-
26-let keyTokenTotalIssuedSupplies = "TOKEN_TOTAL_ISSUED_SUPPLIES"
27-
28-let keyTokenTotalBurnedSupplies = "TOKEN_TOTAL_BURNED_SUPPLIES"
29-
30-let keyAssetOngoingContracts = "ASSET_ONGOING_CONTRACTS_"
31-
32-let keyAssetIssuedContracts = "ASSET_ISSUED_CONTRACTS_"
33-
34-let keyAssetBurnedContracts = "ASSET_BURNED_CONTRACTS_"
35-
36-let keyTotalOngoingContracts = "TOTAL_ONGOING_CONTRACTS"
37-
38-let keyTotalIssuedContracts = "TOTAL_ISSUED_CONTRACTS"
39-
40-let keyTotalBurnedContracts = "TOTAL_BURNED_CONTRACTS"
41-
42-let tokenId = base58'7J7kaZgCXKkWFxjths5ZuMGsrkpxoawPBUGaFvzpHe7V'
43-
44-let tokenEligibilityPerBlock = (10 * 100000000)
45-
46-func getStringOrEmpty (key) = match getString(this, key) {
47- case dataFound: String =>
48- dataFound
49- case _ =>
50- ""
51-}
52-
53-
54-func getIntegerOrZero (key) = match getInteger(this, key) {
55- case isAnInteger: Int =>
56- isAnInteger
57- case _ =>
58- 0
59-}
60-
61-
62-func getNewNonce () = {
63- let incrNonce = (getIntegerOrZero(keyNonce) + 1)
64-[parseIntValue((toString(incrNonce) + toString(height))), incrNonce]
65- }
664
675
686 @Callable(i)
69-func depositToStake () = if ((this == i.caller))
70- then throw("dApp can't interact with self")
71- else if ((size(i.payments) != 1))
72- then throw("Not a valid amount of payments (require 1)")
73- else if ((1 > i.payments[0].amount))
74- then throw("Can't stake negatif or zero")
75- else {
76- let assetId = match i.payments[0].assetId {
77- case isAnAsset: ByteVector =>
78- toBase58String(isAnAsset)
79- case _ =>
80- hcWaves
81- }
82- if ((contains(getStringOrEmpty(keyStakingWhitelist), assetId) != true))
83- then throw("Asset not on staking whitelist")
84- else {
85- let nonce = getNewNonce()
86- let contractDesc = ((((((((toString(versionStakeContract) + hcSeparator) + toString(height)) + hcSeparator) + toBase58String(i.caller.bytes)) + hcSeparator) + assetId) + hcSeparator) + toString(i.payments[0].amount))
87- let contractIssue = Issue(keyStakeContractName, contractDesc, 1, 0, false, unit, nonce[0])
88- let contractId = calculateAssetId(contractIssue)
89- let newLockedAmount = (getIntegerOrZero((keyLockedAmount + assetId)) + i.payments[0].amount)
90- let newAssetOngoingContracts = (getIntegerOrZero((keyAssetOngoingContracts + assetId)) + 1)
91- let newAssetIssuedContracts = (getIntegerOrZero((keyAssetIssuedContracts + assetId)) + 1)
92- let newTotalOngoingContracts = (getIntegerOrZero(keyTotalOngoingContracts) + 1)
93- let newTotalIssuedContracts = (getIntegerOrZero(keyTotalIssuedContracts) + 1)
94-[IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyLockedAmount + assetId), newLockedAmount), IntegerEntry((keyAssetOngoingContracts + assetId), newAssetOngoingContracts), IntegerEntry((keyAssetIssuedContracts + assetId), newAssetIssuedContracts), IntegerEntry(keyTotalOngoingContracts, newTotalOngoingContracts), IntegerEntry(keyTotalIssuedContracts, newTotalIssuedContracts), contractIssue, ScriptTransfer(i.caller, contractIssue.quantity, contractId)]
95- }
96- }
97-
98-
99-
100-@Callable(i)
101-func withdrawStake () = if ((this == i.caller))
102- then throw("dApp can't interact with self")
103- else if ((size(i.payments) != 1))
104- then throw("Not a valid amount of payments (require 1)")
105- else if ((1 > i.payments[0].amount))
106- then throw("Can't stake negatif or zero")
107- else {
108- let assetId = match i.payments[0].assetId {
109- case isByteVector: ByteVector =>
110- isByteVector
111- case _ =>
112- throw("Not an Asset")
113- }
114- let contractInfo = match assetInfo(assetId) {
115- case isAnAsset: Asset =>
116- isAnAsset
117- case _ =>
118- throw("Couldn't find Asset")
119- }
120- if (if (if (if (if ((contractInfo.issuer != this))
121- then true
122- else (contractInfo.decimals != 0))
123- then true
124- else (contractInfo.quantity != 1))
125- then true
126- else (contractInfo.reissuable != false))
127- then true
128- else (contractInfo.name != keyStakeContractName))
129- then throw("Not a Contract")
130- else {
131- let contractDescArray = split(contractInfo.description, hcSeparator)
132- let contractVersion = parseIntValue(contractDescArray[0])
133- let contractStartingHeight = parseIntValue(contractDescArray[1])
134- let contractStakerId = contractDescArray[2]
135- let contractAsset = match assetInfo(fromBase58String(contractDescArray[3])) {
136- case isAnAsset: Asset =>
137- isAnAsset
138- case _ =>
139- throw("Contract error: asset")
140- }
141- let contractAssetAmount = parseIntValue(contractDescArray[4])
142- if ((size(contractDescArray) != 5))
143- then throw("Contract error: corrupted")
144- else if ((contractVersion > versionStakeContract))
145- then throw("Contract error: version")
146- else if ((contractStartingHeight >= height))
147- then throw("Contract error: starting height")
148- else if (if ((1 > contractAssetAmount))
149- then true
150- else (contractAssetAmount > contractAsset.quantity))
151- then throw("Contract error: quantity")
152- else if ((contractAssetAmount > assetBalance(this, contractAsset.id)))
153- then throw("Contract error: dApp balance")
154- else {
155- let assetIdString = toBase58String(contractAsset.id)
156- let blocksAway = (height - contractStartingHeight)
157- let userTokenEligibility = (blocksAway * tokenEligibilityPerBlock)
158- let currentAssetLockedAmount = getIntegerValue(this, (keyLockedAmount + contractDescArray[3]))
159- let userTokenAmountToReceive = fraction(userTokenEligibility, contractAssetAmount, currentAssetLockedAmount)
160- let nonce = getNewNonce()
161- let tokenInfo = match assetInfo(tokenId) {
162- case isAnAsset: Asset =>
163- isAnAsset
164- case _ =>
165- throw("Token not existing bro")
166- }
167- let receiptDesc = ((((((((((contractStakerId + " has locked ") + toString(contractAssetAmount)) + "
168- ") + contractAsset.name) + " during ") + toString(blocksAway)) + " blocks and received ") + toString(userTokenAmountToReceive)) + " ") + tokenInfo.name)
169- let receiptIssue = Issue(keyStakeReceiptName, receiptDesc, 1, 0, false, unit, nonce[0])
170- let receiptId = calculateAssetId(receiptIssue)
171- let newLockedAmount = (getIntegerValue(this, (keyLockedAmount + contractDescArray[3])) - contractAssetAmount)
172- let newCirculatingSupplies = (getIntegerOrZero(keyTokenCirculatingSupplies) + userTokenAmountToReceive)
173- let newTotalIssuedSupplies = (getIntegerOrZero(keyTokenTotalIssuedSupplies) + userTokenAmountToReceive)
174- let newAssetOngoingContracts = (getIntegerOrZero((keyAssetOngoingContracts + assetIdString)) - 1)
175- let newAssetBurnedContracts = (getIntegerOrZero((keyAssetBurnedContracts + assetIdString)) + 1)
176- let newTotalOngoingContracts = (getIntegerOrZero(keyTotalOngoingContracts) - 1)
177- let newTotalBurnedContracts = (getIntegerOrZero(keyTotalBurnedContracts) + 1)
178-[Burn(assetId, 1), IntegerEntry((keyLockedAmount + contractDescArray[3]), newLockedAmount), IntegerEntry(keyTokenCirculatingSupplies, newCirculatingSupplies), IntegerEntry(keyTokenTotalIssuedSupplies, newTotalIssuedSupplies), IntegerEntry((keyAssetOngoingContracts + assetIdString), newAssetOngoingContracts), IntegerEntry((keyAssetBurnedContracts + assetIdString), newAssetBurnedContracts), IntegerEntry(keyTotalOngoingContracts, newTotalOngoingContracts), IntegerEntry(keyTotalBurnedContracts, newTotalBurnedContracts), receiptIssue, ScriptTransfer(i.caller, receiptIssue.quantity, receiptId), ScriptTransfer(i.caller, contractAssetAmount, contractAsset.id), Reissue(tokenId, userTokenAmountToReceive, true), ScriptTransfer(i.caller, userTokenAmountToReceive, tokenId)]
179- }
180- }
181- }
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+ }
18212
18313
18414 @Verifier(tx)
18515 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
18616

github/deemru/w8io/169f3d6 
30.06 ms