tx · J2LFZQFo4NpoFCeTywdJhGgUrnsFzagT1s7pmQD7jFT9 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF: -0.01400000 Waves 2020.03.11 22:27 [904906] smart account 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF > SELF 0.00000000 Waves
{ "type": 13, "id": "J2LFZQFo4NpoFCeTywdJhGgUrnsFzagT1s7pmQD7jFT9", "fee": 1400000, "feeAssetId": null, "timestamp": 1583954882617, "version": 1, "sender": "3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF", "senderPublicKey": "9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3", "proofs": [ "22XmLnK853BDRX7f3bmJo2ejc3z6DQxWKX7bhh2QPkanAuEASCtwrzaimRmzzyYkJFkh2CM7PS49ZbbXkbKf5hjg" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASABIDCgEBAAAABQAAAAAGRVVDb2luAQAAACDJofoUphCC2vgdQrn0R0tQm4QOreBLRVolNScltI/WUQAAAAAGVVNDb2luAQAAACCWpimiLpI8FZFaHXIW3ZwI74bEgcPecoAv5ODcRcQ7/QAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIIR0OzhzTJc1ozXjp3CfISpQxO2vbrCrTGSiFABFRe8mAAAAAA1PcmFjbGVBZGRyZXNzCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNOQWNvZVdkVVRXbjhjc1hKUEc0N3YxRmp0amNmcXhiNXR1AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAADU9yYWNsZUFkZHJlc3MFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAAAABAAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdA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AAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGBwVx2Ls=", "chainId": 84, "height": 904906, "spentComplexity": 0 } View: original | compacted Prev: 8sQt1rbCfmgMkaT1YCXhAG72QuAqLKqUbXTVDN2hjgWv Next: Ds97igpf2vjYHsWmMmgG3QUU5FWDbV535fbeFYDNareb Diff:
Old | New | Differences | |
---|---|---|---|
7 | 7 | ||
8 | 8 | let ownerPublicKey = base58'9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3' | |
9 | 9 | ||
10 | - | let OracleAddress = | |
10 | + | let OracleAddress = addressFromStringValue("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu") | |
11 | 11 | ||
12 | 12 | func getNumberByKey (key) = match getInteger(OracleAddress, key) { | |
13 | 13 | case a: Int => |
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 | - | let OracleAddress = | |
10 | + | let OracleAddress = addressFromStringValue("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 | 47 | let rate = match getInteger(OracleAddress, "waves_usd_2") { | |
48 | 48 | case a: Int => | |
49 | 49 | a | |
50 | 50 | case _ => | |
51 | 51 | 0 | |
52 | 52 | } | |
53 | 53 | if ((rate == 0)) | |
54 | 54 | then throw("rate 0") | |
55 | 55 | else { | |
56 | 56 | let trasferAmount = pmt.amount | |
57 | 57 | let newAmount = (currentAmount + pmt.amount) | |
58 | 58 | ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) | |
59 | 59 | } | |
60 | 60 | } | |
61 | 61 | } | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | ||
65 | 65 | @Callable(i) | |
66 | 66 | func withdrawUSCoin () = { | |
67 | 67 | let pmt = extract(i.payment) | |
68 | 68 | if (isDefined(pmt.assetId)) | |
69 | 69 | then if ((pmt.assetId == EUCoin)) | |
70 | 70 | then { | |
71 | 71 | let currentKey = toBase58String(i.caller.bytes) | |
72 | 72 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
73 | 73 | case a: Int => | |
74 | 74 | a | |
75 | 75 | case _ => | |
76 | 76 | 0 | |
77 | 77 | } | |
78 | 78 | let rate = getNumberByKey("waves_usd_2") | |
79 | 79 | let trasferAmount = (pmt.amount / 100) | |
80 | 80 | let newAmount = (currentAmount - trasferAmount) | |
81 | 81 | if ((0 > pmt.amount)) | |
82 | 82 | then throw("Can't withdraw negative amount") | |
83 | 83 | else if ((0 > newAmount)) | |
84 | 84 | then throw("Not enough USCoin Deposited") | |
85 | 85 | else ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, USCoin)])) | |
86 | 86 | } | |
87 | 87 | else throw("You Can Withdraw with EUCoin only") | |
88 | 88 | else throw("You Can Withdraw with EUCoin only") | |
89 | 89 | } | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(i) | |
94 | 94 | func withdrawWaves () = { | |
95 | 95 | let pmt = extract(i.payment) | |
96 | 96 | if (isDefined(pmt.assetId)) | |
97 | 97 | then if ((pmt.assetId == EUCoin)) | |
98 | 98 | then { | |
99 | 99 | let currentKey = toBase58String(i.caller.bytes) | |
100 | 100 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
101 | 101 | case a: Int => | |
102 | 102 | a | |
103 | 103 | case _ => | |
104 | 104 | 0 | |
105 | 105 | } | |
106 | 106 | let rate = getNumberByKey("waves_usd_2") | |
107 | 107 | let trasferAmount = pmt.amount | |
108 | 108 | let newAmount = (currentAmount - trasferAmount) | |
109 | 109 | if ((0 > pmt.amount)) | |
110 | 110 | then throw("Can't withdraw negative amount") | |
111 | 111 | else if ((0 > newAmount)) | |
112 | 112 | then throw("Not enough Waves Deposited") | |
113 | 113 | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
114 | 114 | } | |
115 | 115 | else throw("You Can Withdraw with EUCoin only") | |
116 | 116 | else throw("You Can Withdraw with EUCoin only") | |
117 | 117 | } | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Callable(i) | |
122 | 122 | func getFaucet (amount) = { | |
123 | 123 | let currentKey = toBase58String(i.caller.bytes) | |
124 | 124 | let currentAmount = match getInteger(this, (currentKey + "_faucet")) { | |
125 | 125 | case a: Int => | |
126 | 126 | a | |
127 | 127 | case _ => | |
128 | 128 | 0 | |
129 | 129 | } | |
130 | 130 | if ((0 > amount)) | |
131 | 131 | then throw("Can't withdraw negative amount") | |
132 | 132 | else if ((currentAmount > 0)) | |
133 | 133 | then throw("Faucet already taken") | |
134 | 134 | else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)])) | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | @Verifier(tx) | |
139 | 139 | func verify () = match tx { | |
140 | 140 | case d: SetScriptTransaction => | |
141 | 141 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
142 | 142 | case d: DataTransaction => | |
143 | 143 | true | |
144 | 144 | case _ => | |
145 | 145 | false | |
146 | 146 | } | |
147 | 147 |
github/deemru/w8io/169f3d6 43.94 ms ◑