tx · GSCiShWzB6Mzf1kREHM4bdrG1SxVqp8RkBy3RHqAwYTM 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF: -0.01400000 Waves 2020.03.11 21:48 [904861] smart account 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF > SELF 0.00000000 Waves
{ "type": 13, "id": "GSCiShWzB6Mzf1kREHM4bdrG1SxVqp8RkBy3RHqAwYTM", "fee": 1400000, "feeAssetId": null, "timestamp": 1583952510174, "version": 1, "sender": "3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF", "senderPublicKey": "9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3", "proofs": [ "m5mbs5q9jM8A1twvq3UF2mVcLmpdhwK6RLEuG6bYbGMvjx6bvc7Wvutfo8H4LwzHt3nF2CBqjWZQy2Zm6tzt6KH" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASABIDCgEBAAAABQAAAAAGRVVDb2luAQAAACDJofoUphCC2vgdQrn0R0tQm4QOreBLRVolNScltI/WUQAAAAAGVVNDb2luAQAAACCWpimiLpI8FZFaHXIW3ZwI74bEgcPecoAv5ODcRcQ7/QAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIIR0OzhzTJc1ozXjp3CfISpQxO2vbrCrTGSiFABFRe8mAAAAAA1PcmFjbGVBZGRyZXNzCQEAAAAHQWRkcmVzcwAAAAEJAAGbAAAAAQIAAAAjM05BY29lV2RVVFduOGNzWEpQRzQ3djFGanRqY2ZxeGI1dHUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAANT3JhY2xlQWRkcmVzcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAAAAAEAAAAAWkBAAAAB2RlcG9zaXQAAAAABAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAW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AAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgeZWYSF", "chainId": 84, "height": 904861, "spentComplexity": 0 } View: original | compacted Prev: 8eAZXqdiowrtgvgRXTPy9oT42cDPR1LfHqg1pD5BHSdB Next: 8sQt1rbCfmgMkaT1YCXhAG72QuAqLKqUbXTVDN2hjgWv Diff:
Old | New | Differences | |
---|---|---|---|
44 | 44 | case _ => | |
45 | 45 | 0 | |
46 | 46 | } | |
47 | - | let rate = getNumberByKey("waves_usd_2") | |
47 | + | let rate = match getInteger(OracleAddress, "waves_usd_2") { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | 0 | |
52 | + | } | |
48 | 53 | let trasferAmount = pmt.amount | |
49 | 54 | let newAmount = (currentAmount + pmt.amount) | |
50 | 55 | ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let EUCoin = base58'Ea6CdDfumo8ZFecxUSWKAjZpQXmkRC79WB4ktu3KffPn' | |
5 | 5 | ||
6 | 6 | let USCoin = base58'B957NA5BEM8quCDhe1fUPkqBSdCZdJunNxjGE8FRJkWx' | |
7 | 7 | ||
8 | 8 | let ownerPublicKey = base58'9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3' | |
9 | 9 | ||
10 | 10 | let OracleAddress = Address(toBytes("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu")) | |
11 | 11 | ||
12 | 12 | func getNumberByKey (key) = match getInteger(OracleAddress, key) { | |
13 | 13 | case a: Int => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | 0 | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | @Callable(i) | |
21 | 21 | func deposit () = { | |
22 | 22 | let pmt = extract(i.payment) | |
23 | 23 | if (isDefined(pmt.assetId)) | |
24 | 24 | then if ((pmt.assetId == USCoin)) | |
25 | 25 | then { | |
26 | 26 | let currentKey = toBase58String(i.caller.bytes) | |
27 | 27 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
28 | 28 | case a: Int => | |
29 | 29 | a | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | let rate = getNumberByKey("waves_usd_2") | |
34 | 34 | let trasferAmount = (pmt.amount * 100) | |
35 | 35 | let newAmount = (currentAmount + pmt.amount) | |
36 | 36 | ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) | |
37 | 37 | } | |
38 | 38 | else throw("can hodl USCoin only at the moment") | |
39 | 39 | else { | |
40 | 40 | let currentKey = toBase58String(i.caller.bytes) | |
41 | 41 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
42 | 42 | case a: Int => | |
43 | 43 | a | |
44 | 44 | case _ => | |
45 | 45 | 0 | |
46 | 46 | } | |
47 | - | let rate = getNumberByKey("waves_usd_2") | |
47 | + | let rate = match getInteger(OracleAddress, "waves_usd_2") { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | 0 | |
52 | + | } | |
48 | 53 | let trasferAmount = pmt.amount | |
49 | 54 | let newAmount = (currentAmount + pmt.amount) | |
50 | 55 | ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) | |
51 | 56 | } | |
52 | 57 | } | |
53 | 58 | ||
54 | 59 | ||
55 | 60 | ||
56 | 61 | @Callable(i) | |
57 | 62 | func withdrawUSCoin () = { | |
58 | 63 | let pmt = extract(i.payment) | |
59 | 64 | if (isDefined(pmt.assetId)) | |
60 | 65 | then if ((pmt.assetId == EUCoin)) | |
61 | 66 | then { | |
62 | 67 | let currentKey = toBase58String(i.caller.bytes) | |
63 | 68 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
64 | 69 | case a: Int => | |
65 | 70 | a | |
66 | 71 | case _ => | |
67 | 72 | 0 | |
68 | 73 | } | |
69 | 74 | let rate = getNumberByKey("waves_usd_2") | |
70 | 75 | let trasferAmount = (pmt.amount / 100) | |
71 | 76 | let newAmount = (currentAmount - trasferAmount) | |
72 | 77 | if ((0 > pmt.amount)) | |
73 | 78 | then throw("Can't withdraw negative amount") | |
74 | 79 | else if ((0 > newAmount)) | |
75 | 80 | then throw("Not enough USCoin Deposited") | |
76 | 81 | else ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, USCoin)])) | |
77 | 82 | } | |
78 | 83 | else throw("You Can Withdraw with EUCoin only") | |
79 | 84 | else throw("You Can Withdraw with EUCoin only") | |
80 | 85 | } | |
81 | 86 | ||
82 | 87 | ||
83 | 88 | ||
84 | 89 | @Callable(i) | |
85 | 90 | func withdrawWaves () = { | |
86 | 91 | let pmt = extract(i.payment) | |
87 | 92 | if (isDefined(pmt.assetId)) | |
88 | 93 | then if ((pmt.assetId == EUCoin)) | |
89 | 94 | then { | |
90 | 95 | let currentKey = toBase58String(i.caller.bytes) | |
91 | 96 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
92 | 97 | case a: Int => | |
93 | 98 | a | |
94 | 99 | case _ => | |
95 | 100 | 0 | |
96 | 101 | } | |
97 | 102 | let rate = getNumberByKey("waves_usd_2") | |
98 | 103 | let trasferAmount = pmt.amount | |
99 | 104 | let newAmount = (currentAmount - trasferAmount) | |
100 | 105 | if ((0 > pmt.amount)) | |
101 | 106 | then throw("Can't withdraw negative amount") | |
102 | 107 | else if ((0 > newAmount)) | |
103 | 108 | then throw("Not enough Waves Deposited") | |
104 | 109 | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
105 | 110 | } | |
106 | 111 | else throw("You Can Withdraw with EUCoin only") | |
107 | 112 | else throw("You Can Withdraw with EUCoin only") | |
108 | 113 | } | |
109 | 114 | ||
110 | 115 | ||
111 | 116 | ||
112 | 117 | @Callable(i) | |
113 | 118 | func getFaucet (amount) = { | |
114 | 119 | let currentKey = toBase58String(i.caller.bytes) | |
115 | 120 | let currentAmount = match getInteger(this, (currentKey + "_faucet")) { | |
116 | 121 | case a: Int => | |
117 | 122 | a | |
118 | 123 | case _ => | |
119 | 124 | 0 | |
120 | 125 | } | |
121 | 126 | if ((0 > amount)) | |
122 | 127 | then throw("Can't withdraw negative amount") | |
123 | 128 | else if ((currentAmount > 0)) | |
124 | 129 | then throw("Faucet already taken") | |
125 | 130 | else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)])) | |
126 | 131 | } | |
127 | 132 | ||
128 | 133 | ||
129 | 134 | @Verifier(tx) | |
130 | 135 | func verify () = match tx { | |
131 | 136 | case d: SetScriptTransaction => | |
132 | 137 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
133 | 138 | case d: DataTransaction => | |
134 | 139 | true | |
135 | 140 | case _ => | |
136 | 141 | false | |
137 | 142 | } | |
138 | 143 |
github/deemru/w8io/169f3d6 32.51 ms ◑