tx · 6KRJvR4qcEFmVvFEF6YB6P47xL1X8GX5WWG7YsKropwU

3NBNKJTqCGbPCDw1A86tAH3oLjFfhAmUYKW:  -0.00600000 Waves

2022.08.26 15:10 [2201430] smart account 3NBNKJTqCGbPCDw1A86tAH3oLjFfhAmUYKW > SELF 0.00000000 Waves

{ "type": 13, "id": "6KRJvR4qcEFmVvFEF6YB6P47xL1X8GX5WWG7YsKropwU", "fee": 600000, "feeAssetId": null, "timestamp": 1661515791225, "version": 2, "chainId": 84, "sender": "3NBNKJTqCGbPCDw1A86tAH3oLjFfhAmUYKW", "senderPublicKey": "5KgB1ZojKX7qznjw2mAXoU9asTrLAHv5nEvk36suSN3c", "proofs": [ "5LMJmF7HT5LqKT5Gmt8dtYocovmw3osPxY499VUSdC9xxwJRPcv8SpJHqEP9QZ5nXu6uBfubZgmbnGDkqhUSpsdL" ], "script": "base64:BgIHCAISAwoBAQEABGRhcHABGgFU61C/dqMfxvABbM6dnx1tiGfoEC0nPfYlAQFpAQlmcmVlV2F2ZXMBBmFtb3VudAMJAGYCBQZhbW91bnQAgISvXwkAAgECGXRoZSBtYXggYW1vdW50IGlzIDIgd2F2ZXMEBnNlbmRlcggFAWkGY2FsbGVyBApzZW5kZXJfa2V5CQCsAgIJAKUIAQUGc2VuZGVyAgZfV0FWRVMEDGdldE9sZEFtb3VudAkAmggCBQR0aGlzBQpzZW5kZXJfa2V5BAlvbGRBbW91bnQEByRtYXRjaDAFDGdldE9sZEFtb3VudAMJAAECBQckbWF0Y2gwAgNJbnQEAmluBQckbWF0Y2gwCQBkAgUCaW4AAAMJAAECBQckbWF0Y2gwAgRVbml0BAJ1bgUHJG1hdGNoMAAAAAADCQBmAgUJb2xkQW1vdW50AICo1rkHCQACAQImdGhlIG1heCBhbW91bnQgdG8gd2l0aGRyYXcgaXMgMTAgd2F2ZXMECW5ld0Ftb3VudAkAZAIFCW9sZEFtb3VudAUGYW1vdW50BARzYXZlCQEMSW50ZWdlckVudHJ5AgUKc2VuZGVyX2tleQUJbmV3QW1vdW50BAh0cmFuc2ZlcgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyBQZhbW91bnQFBHVuaXQJAMwIAgUIdHJhbnNmZXIJAMwIAgUEc2F2ZQUDbmlsAFb1oto=", "height": 2201430, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: E5LmmHMfXY9bchycWQ64mbHat3EX8nXBJw2KjNesLx2u Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let usdn = base58'FVXgJ86erBw5GAMeAw1CnYXwQn48BFAEAhRyHPUjbMQB'
5-
6-let usdc = base58'HRut8ESAGXxwvsKJky1V96qRtqyXQd4Apq4GY7TE5yGP'
7-
8-let admin_wallet = "3N3DCngjidivkJbTJwFTEvbYRTffCWVBLCL"
9-
10-let alfark_testnet = 5
11-
12-let vires_dapp = base58'3MzwNdM8LQZEPXq3d4uXvxeZGpBwVQXs9RD'
13-
14-func tryGetInteger (key) = match getInteger(this, key) {
15- case b: Int =>
16- b
17- case _ =>
18- 0
19-}
20-
4+let dapp = base58'3NBNKJTqCGbPCDw1A86tAH3oLjFfhAmUYKW'
215
226 @Callable(i)
23-func buy_usdn_ticket () = if ((i.payments[0].assetId != usdn))
24- then throw("Please deposit USD-N token only")
7+func freeWaves (amount) = if ((amount > 200000000))
8+ then throw("the max amount is 2 waves")
259 else {
26- let user_credit = tryGetInteger((("usdn_" + toString(i.originCaller)) + "_credit"))
27- let deposit_amount = i.payments[0].amount
28- let new_user_credit = (user_credit + deposit_amount)
29- let all_credit = tryGetInteger("usdn_all_credit")
30- let new_all_credit = (all_credit + deposit_amount)
31- let transaction_block = match lastBlock.height {
32- case a: Int =>
33- a
10+ let sender = i.caller
11+ let sender_key = (toString(sender) + "_WAVES")
12+ let getOldAmount = getInteger(this, sender_key)
13+ let oldAmount = match getOldAmount {
14+ case in: Int =>
15+ (in + 0)
16+ case un: Unit =>
17+ 0
3418 case _ =>
35- throw("Error! with blochchain height")
19+ 0
3620 }
37- let res = invoke(Address(vires_dapp), "usdN_stake", nil, [AttachedPayment(usdn, deposit_amount)])
38- if ((res == res))
39- then [IntegerEntry((("usdn_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdn_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdn_all_credit", new_all_credit), IntegerEntry("usdn_all_block", transaction_block)]
40- else throw("Strict value is not equal to itself.")
41- }
42-
43-
44-
45-@Callable(i)
46-func buy_usdc_ticket () = if ((i.payments[0].assetId != usdc))
47- then throw("Please deposit USD-N token only")
48- else {
49- let user_credit = tryGetInteger((("usdc_" + toString(i.originCaller)) + "_credit"))
50- let deposit_amount = i.payments[0].amount
51- let new_user_credit = (user_credit + deposit_amount)
52- let all_credit = tryGetInteger("usdc_all_credit")
53- let new_all_credit = (all_credit + deposit_amount)
54- let transaction_block = match lastBlock.height {
55- case a: Int =>
56- a
57- case _ =>
58- throw("Error block number")
59- }
60- let res = invoke(Address(vires_dapp), "usdC_stake", nil, [AttachedPayment(usdc, deposit_amount)])
61- if ((res == res))
62- then [IntegerEntry((("usdc_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdc_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdc_all_credit", new_all_credit), IntegerEntry("usdc_all_block", transaction_block)]
63- else throw("Strict value is not equal to itself.")
64- }
65-
66-
67-
68-@Callable(i)
69-func sell_usdn_ticket (amount) = {
70- let user_credit = tryGetInteger((("usdn_" + toString(i.originCaller)) + "_credit"))
71- if ((amount > user_credit))
72- then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(user_credit)))
73- else {
74- let new_user_credit = (user_credit - amount)
75- let all_credit = tryGetInteger("usdn_all_credit")
76- let new_all_credit = (all_credit - amount)
77- let transaction_block = match lastBlock.height {
78- case a: Int =>
79- a
80- case _ =>
81- throw("Error block number")
82- }
83- let res = invoke(Address(vires_dapp), "usdN_cancelStake", [amount], nil)
84- if ((res == res))
85- then [IntegerEntry((("usdn_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdn_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdn_all_credit", new_all_credit), IntegerEntry("usdn_all_block", transaction_block)]
86- else throw("Strict value is not equal to itself.")
87- }
88- }
89-
90-
91-
92-@Callable(i)
93-func sell_usdc_ticket (amount) = {
94- let user_credit = tryGetInteger((("usdc_" + toString(i.originCaller)) + "_credit"))
95- if ((amount > user_credit))
96- then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(user_credit)))
97- else {
98- let new_user_credit = (user_credit - amount)
99- let all_credit = tryGetInteger("usdc_all_credit")
100- let new_all_credit = (all_credit - amount)
101- let transaction_block = match lastBlock.height {
102- case a: Int =>
103- a
104- case _ =>
105- throw("Error block number")
106- }
107- let res = invoke(Address(vires_dapp), "usdC_cancelStake", [amount], nil)
108- if ((res == res))
109- then [IntegerEntry((("usdc_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdc_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdc_all_credit", new_all_credit), IntegerEntry("usdc_all_block", transaction_block)]
110- else throw("Strict value is not equal to itself.")
111- }
112- }
113-
114-
115-
116-@Callable(i)
117-func usdn_calc_profit_amount () = if ((toString(i.originCaller) != admin_wallet))
118- then throw("Sorry! you are not allowed to use this funaction")
119- else {
120- let usdn_profit_last_block = tryGetInteger("usdn_profit_last_block")
121- let usdn_profit_last_amount = tryGetInteger("usdn_profit_last_amount")
122- let transaction_block = match lastBlock.height {
123- case a: Int =>
124- a
125- case _ =>
126- throw("Error block number")
127- }
128- let alfark = (transaction_block - usdn_profit_last_block)
129- if ((alfark_testnet > alfark))
130- then throw((("Please try again after " + toString((alfark_testnet - alfark))) + " block"))
21+ if ((oldAmount > 2000000000))
22+ then throw("the max amount to withdraw is 10 waves")
13123 else {
132- let usdn_balance = assetBalance(this, usdn)
133-[IntegerEntry("usdn_profit_last_block", transaction_block), IntegerEntry("usdn_profit_last_amount", usdn_balance)]
24+ let newAmount = (oldAmount + amount)
25+ let save = IntegerEntry(sender_key, newAmount)
26+ let transfer = ScriptTransfer(i.caller, amount, unit)
27+[transfer, save]
13428 }
13529 }
13630
137-
138-
139-@Callable(i)
140-func usdn_send_profit_amount () = {
141- let usdn_profit_last_amount = tryGetInteger("usdn_profit_last_amount")
142- if ((0 >= usdn_profit_last_amount))
143- then throw(("you dont have profit amount " + toString(usdn_profit_last_amount)))
144- else {
145- let transfer = ScriptTransfer(addressFromStringValue(admin_wallet), usdn_profit_last_amount, usdn)
146-[transfer]
147- }
148- }
149-
150-
151-
152-@Callable(i)
153-func usdc_calc_profit_amount () = if ((toString(i.originCaller) != admin_wallet))
154- then throw("Sorry! you are not allowed to use this funaction")
155- else {
156- let usdc_profit_last_block = tryGetInteger("usdc_profit_last_block")
157- let usdc_profit_last_amount = tryGetInteger("usdc_profit_last_amount")
158- let transaction_block = match lastBlock.height {
159- case a: Int =>
160- a
161- case _ =>
162- throw("Error block number")
163- }
164- let alfark = (transaction_block - usdc_profit_last_block)
165- if ((alfark_testnet > alfark))
166- then throw((("Please try again after " + toString((alfark_testnet - alfark))) + " block"))
167- else {
168- let usdc_balance = assetBalance(this, usdc)
169-[IntegerEntry("usdc_profit_last_block", transaction_block), IntegerEntry("usdc_profit_last_amount", usdc_balance)]
170- }
171- }
172-
173-
174-
175-@Callable(i)
176-func usdc_send_profit_amount () = {
177- let usdc_profit_last_amount = tryGetInteger("usdc_profit_last_amount")
178- if ((0 >= usdc_profit_last_amount))
179- then throw(("you dont have profit amount " + toString(usdc_profit_last_amount)))
180- else {
181- let transfer = ScriptTransfer(addressFromStringValue(admin_wallet), usdc_profit_last_amount, usdc)
182-[transfer]
183- }
184- }
185-
186-
187-@Verifier(tx)
188-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
18931

github/deemru/w8io/169f3d6 
40.84 ms