tx · 8sQt1rbCfmgMkaT1YCXhAG72QuAqLKqUbXTVDN2hjgWv

3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF:  -0.01400000 Waves

2020.03.11 21:49 [904862] smart account 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF > SELF 0.00000000 Waves

{ "type": 13, "id": "8sQt1rbCfmgMkaT1YCXhAG72QuAqLKqUbXTVDN2hjgWv", "fee": 1400000, "feeAssetId": null, "timestamp": 1583952633136, "version": 1, "sender": "3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF", "senderPublicKey": "9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3", "proofs": [ "5jFcTpLwSMLw4cmyMrwDiRqXztmrgndHHeBD3aSTRRC7jwcnzAsW6ptLJYbS4YQCS6VEzuzdDukQYGNkQjrMvR5Q" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASABIDCgEBAAAABQAAAAAGRVVDb2luAQAAACDJofoUphCC2vgdQrn0R0tQm4QOreBLRVolNScltI/WUQAAAAAGVVNDb2luAQAAACCWpimiLpI8FZFaHXIW3ZwI74bEgcPecoAv5ODcRcQ7/QAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIIR0OzhzTJc1ozXjp3CfISpQxO2vbrCrTGSiFABFRe8mAAAAAA1PcmFjbGVBZGRyZXNzCQEAAAAHQWRkcmVzcwAAAAEJAAGbAAAAAQIAAAAjM05BY29lV2RVVFduOGNzWEpQRzQ3djFGanRqY2ZxeGI1dHUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAANT3JhY2xlQWRkcmVzcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAAAAAEAAAAAWkBAAAAB2RlcG9zaXQAAAAABAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAA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AMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYHsF/JpQ==", "chainId": 84, "height": 904862, "spentComplexity": 0 } View: original | compacted Prev: GSCiShWzB6Mzf1kREHM4bdrG1SxVqp8RkBy3RHqAwYTM Next: J2LFZQFo4NpoFCeTywdJhGgUrnsFzagT1s7pmQD7jFT9 Diff:
OldNewDifferences
5050 case _ =>
5151 0
5252 }
53- let trasferAmount = pmt.amount
54- let newAmount = (currentAmount + pmt.amount)
55- ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)]))
53+ if ((rate == 0))
54+ then throw("rate 0")
55+ else {
56+ let trasferAmount = pmt.amount
57+ let newAmount = (currentAmount + pmt.amount)
58+ ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)]))
59+ }
5660 }
5761 }
5862
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let EUCoin = base58'Ea6CdDfumo8ZFecxUSWKAjZpQXmkRC79WB4ktu3KffPn'
55
66 let USCoin = base58'B957NA5BEM8quCDhe1fUPkqBSdCZdJunNxjGE8FRJkWx'
77
88 let ownerPublicKey = base58'9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3'
99
1010 let OracleAddress = Address(toBytes("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu"))
1111
1212 func getNumberByKey (key) = match getInteger(OracleAddress, key) {
1313 case a: Int =>
1414 a
1515 case _ =>
1616 0
1717 }
1818
1919
2020 @Callable(i)
2121 func deposit () = {
2222 let pmt = extract(i.payment)
2323 if (isDefined(pmt.assetId))
2424 then if ((pmt.assetId == USCoin))
2525 then {
2626 let currentKey = toBase58String(i.caller.bytes)
2727 let currentAmount = match getInteger(this, (currentKey + "_uscoin")) {
2828 case a: Int =>
2929 a
3030 case _ =>
3131 0
3232 }
3333 let rate = getNumberByKey("waves_usd_2")
3434 let trasferAmount = (pmt.amount * 100)
3535 let newAmount = (currentAmount + pmt.amount)
3636 ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)]))
3737 }
3838 else throw("can hodl USCoin only at the moment")
3939 else {
4040 let currentKey = toBase58String(i.caller.bytes)
4141 let currentAmount = match getInteger(this, (currentKey + "_waves")) {
4242 case a: Int =>
4343 a
4444 case _ =>
4545 0
4646 }
4747 let rate = match getInteger(OracleAddress, "waves_usd_2") {
4848 case a: Int =>
4949 a
5050 case _ =>
5151 0
5252 }
53- let trasferAmount = pmt.amount
54- let newAmount = (currentAmount + pmt.amount)
55- ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)]))
53+ if ((rate == 0))
54+ then throw("rate 0")
55+ else {
56+ let trasferAmount = pmt.amount
57+ let newAmount = (currentAmount + pmt.amount)
58+ ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)]))
59+ }
5660 }
5761 }
5862
5963
6064
6165 @Callable(i)
6266 func withdrawUSCoin () = {
6367 let pmt = extract(i.payment)
6468 if (isDefined(pmt.assetId))
6569 then if ((pmt.assetId == EUCoin))
6670 then {
6771 let currentKey = toBase58String(i.caller.bytes)
6872 let currentAmount = match getInteger(this, (currentKey + "_uscoin")) {
6973 case a: Int =>
7074 a
7175 case _ =>
7276 0
7377 }
7478 let rate = getNumberByKey("waves_usd_2")
7579 let trasferAmount = (pmt.amount / 100)
7680 let newAmount = (currentAmount - trasferAmount)
7781 if ((0 > pmt.amount))
7882 then throw("Can't withdraw negative amount")
7983 else if ((0 > newAmount))
8084 then throw("Not enough USCoin Deposited")
8185 else ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, USCoin)]))
8286 }
8387 else throw("You Can Withdraw with EUCoin only")
8488 else throw("You Can Withdraw with EUCoin only")
8589 }
8690
8791
8892
8993 @Callable(i)
9094 func withdrawWaves () = {
9195 let pmt = extract(i.payment)
9296 if (isDefined(pmt.assetId))
9397 then if ((pmt.assetId == EUCoin))
9498 then {
9599 let currentKey = toBase58String(i.caller.bytes)
96100 let currentAmount = match getInteger(this, (currentKey + "_waves")) {
97101 case a: Int =>
98102 a
99103 case _ =>
100104 0
101105 }
102106 let rate = getNumberByKey("waves_usd_2")
103107 let trasferAmount = pmt.amount
104108 let newAmount = (currentAmount - trasferAmount)
105109 if ((0 > pmt.amount))
106110 then throw("Can't withdraw negative amount")
107111 else if ((0 > newAmount))
108112 then throw("Not enough Waves Deposited")
109113 else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)]))
110114 }
111115 else throw("You Can Withdraw with EUCoin only")
112116 else throw("You Can Withdraw with EUCoin only")
113117 }
114118
115119
116120
117121 @Callable(i)
118122 func getFaucet (amount) = {
119123 let currentKey = toBase58String(i.caller.bytes)
120124 let currentAmount = match getInteger(this, (currentKey + "_faucet")) {
121125 case a: Int =>
122126 a
123127 case _ =>
124128 0
125129 }
126130 if ((0 > amount))
127131 then throw("Can't withdraw negative amount")
128132 else if ((currentAmount > 0))
129133 then throw("Faucet already taken")
130134 else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)]))
131135 }
132136
133137
134138 @Verifier(tx)
135139 func verify () = match tx {
136140 case d: SetScriptTransaction =>
137141 sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
138142 case d: DataTransaction =>
139143 true
140144 case _ =>
141145 false
142146 }
143147

github/deemru/w8io/169f3d6 
43.59 ms