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