tx · 4jZtWxoN6tUH5MYMiM5BnwrsZBowbxskuGTKnWc69MUe 3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD: -0.00200000 Waves 2022.07.14 20:56 [2139721] smart account 3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD > SELF 0.00000000 Waves
{ "type": 13, "id": "4jZtWxoN6tUH5MYMiM5BnwrsZBowbxskuGTKnWc69MUe", "fee": 200000, "feeAssetId": null, "timestamp": 1657821452569, "version": 2, "chainId": 84, "sender": "3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD", "senderPublicKey": "CU5wMqCBg4bC4Zgs8QGiqjjvmeMkSiKo3Ff6k5axJZwr", "proofs": [ "5AcyHSrP5xeViLNUbikRMKDbtBC9hdWRSVDaRXALBLXXVyvoLHUvojRXyKgKddePuffeFNAqHcUiQsoacGuFvCxc" ], "script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAABAAAAAAdnZ1Rva2VuAQAAACBrVOjHv/ccQBeJZW/zYCjZI72Il39H9014vm+87tzFkAAAAAIAAAABaQEAAAAHZGVwb3NpdAAAAAAEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50AwkBAAAAAiE9AAAAAggFAAAAA3BtdAAAAAdhc3NldElkBQAAAAdnZ1Rva2VuCQAAAgAAAAECAAAATmdnVG9rZW4gOER5aWR2cTh5a1d4bXY2Q3haWlhRdGRqMWFrdGl3UHY0aWJnR1dUZ3hvNWggdG9rZW5zIG9ubHkgYXQgdGhlIG1vbWVudAQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAAJbmV3QW1vdW50CQAAZAAAAAIFAAAADWN1cnJlbnRBbW91bnQIBQAAAANwbXQAAAAGYW1vdW50CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApjdXJyZW50S2V5BQAAAAluZXdBbW91bnQFAAAAA25pbAAAAAFpAQAAAAh3aXRoZHJhdwAAAAEAAAAGYW1vdW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAADWN1cnJlbnRBbW91bnQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKY3VycmVudEtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAAluZXdBbW91bnQJAABlAAAAAgUAAAANY3VycmVudEFtb3VudAUAAAAGYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAZhbW91bnQJAAACAAAAAQIAAAAeQ2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAluZXdBbW91bnQJAAACAAAAAQIAAAASTm90IGVub3VnaCBiYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAAAGziiX", "height": 2139721, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: D6MbMuk1EUqS8UQ3Z34NeEFBv5rSJm8YteXRWvNRWAxH Next: 4RQ2WLP9sGHKEQKhbLy1WXP3upJt3SipYVEFqywvDKEy Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | ||
4 | + | let ggToken = base58'8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func deposit () = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | - | if ( | |
10 | - | then throw(" | |
9 | + | if ((pmt.assetId != ggToken)) | |
10 | + | then throw("ggToken 8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h tokens only at the moment") | |
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
14 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
13 | + | let currentAmount = match getInteger(this, currentKey) { | |
15 | 14 | case a: Int => | |
16 | 15 | a | |
17 | 16 | case _ => | |
18 | 17 | 0 | |
19 | 18 | } | |
20 | 19 | let newAmount = (currentAmount + pmt.amount) | |
21 | - | WriteSet([DataEntry( | |
20 | + | WriteSet([DataEntry(currentKey, newAmount)]) | |
22 | 21 | } | |
23 | 22 | } | |
24 | 23 | ||
27 | 26 | @Callable(i) | |
28 | 27 | func withdraw (amount) = { | |
29 | 28 | let currentKey = toBase58String(i.caller.bytes) | |
30 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
31 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
29 | + | let currentAmount = match getInteger(this, currentKey) { | |
32 | 30 | case a: Int => | |
33 | 31 | a | |
34 | 32 | case _ => | |
39 | 37 | then throw("Can't withdraw negative amount") | |
40 | 38 | else if ((0 > newAmount)) | |
41 | 39 | then throw("Not enough balance") | |
42 | - | else ScriptResult(WriteSet([DataEntry(xxxInvestorBalance, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
43 | - | } | |
44 | - | ||
45 | - | ||
46 | - | ||
47 | - | @Callable(i) | |
48 | - | func getFunds (amount) = { | |
49 | - | let quorum = 2 | |
50 | - | let currentKey = toBase58String(i.caller.bytes) | |
51 | - | let xxxStartupFund = ((currentKey + "_") + "sf") | |
52 | - | let xxxStartupVotes = ((currentKey + "_") + "sv") | |
53 | - | let currentAmount = match getInteger(this, xxxStartupFund) { | |
54 | - | case a: Int => | |
55 | - | a | |
56 | - | case _ => | |
57 | - | 0 | |
58 | - | } | |
59 | - | let totalVotes = match getInteger(this, xxxStartupVotes) { | |
60 | - | case a: Int => | |
61 | - | a | |
62 | - | case _ => | |
63 | - | 0 | |
64 | - | } | |
65 | - | let newAmount = (currentAmount - amount) | |
66 | - | if ((0 > amount)) | |
67 | - | then throw("Can't withdraw negative amount") | |
68 | - | else if ((0 > newAmount)) | |
69 | - | then throw("Not enough balance") | |
70 | - | else if ((quorum > totalVotes)) | |
71 | - | then throw("Not enough votes. At least 2 votes required!") | |
72 | - | else ScriptResult(WriteSet([DataEntry(xxxStartupFund, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
73 | - | } | |
74 | - | ||
75 | - | ||
76 | - | ||
77 | - | @Callable(i) | |
78 | - | func vote (amount,address) = { | |
79 | - | let currentKey = toBase58String(i.caller.bytes) | |
80 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
81 | - | let xxxStartupFund = ((address + "_") + "sf") | |
82 | - | let xxxStartupVotes = ((address + "_") + "sv") | |
83 | - | let flagKey = ((address + "_") + currentKey) | |
84 | - | let flag = match getInteger(this, flagKey) { | |
85 | - | case a: Int => | |
86 | - | a | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
91 | - | case a: Int => | |
92 | - | a | |
93 | - | case _ => | |
94 | - | 0 | |
95 | - | } | |
96 | - | let currentVotes = match getInteger(this, xxxStartupVotes) { | |
97 | - | case a: Int => | |
98 | - | a | |
99 | - | case _ => | |
100 | - | 0 | |
101 | - | } | |
102 | - | let currentFund = match getInteger(this, xxxStartupFund) { | |
103 | - | case a: Int => | |
104 | - | a | |
105 | - | case _ => | |
106 | - | 0 | |
107 | - | } | |
108 | - | if ((0 >= amount)) | |
109 | - | then throw("Can't withdraw negative amount") | |
110 | - | else if ((amount > currentAmount)) | |
111 | - | then throw("Not enough balance!") | |
112 | - | else if ((flag > 0)) | |
113 | - | then throw("Only one vote per project is possible!") | |
114 | - | else WriteSet([DataEntry(xxxInvestorBalance, (currentAmount - amount)), DataEntry(xxxStartupVotes, (currentVotes + 1)), DataEntry(flagKey, 1), DataEntry(xxxStartupFund, (currentFund + amount))]) | |
40 | + | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
115 | 41 | } | |
116 | 42 | ||
117 | 43 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | ||
4 | + | let ggToken = base58'8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func deposit () = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | - | if ( | |
10 | - | then throw(" | |
9 | + | if ((pmt.assetId != ggToken)) | |
10 | + | then throw("ggToken 8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h tokens only at the moment") | |
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
14 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
13 | + | let currentAmount = match getInteger(this, currentKey) { | |
15 | 14 | case a: Int => | |
16 | 15 | a | |
17 | 16 | case _ => | |
18 | 17 | 0 | |
19 | 18 | } | |
20 | 19 | let newAmount = (currentAmount + pmt.amount) | |
21 | - | WriteSet([DataEntry( | |
20 | + | WriteSet([DataEntry(currentKey, newAmount)]) | |
22 | 21 | } | |
23 | 22 | } | |
24 | 23 | ||
25 | 24 | ||
26 | 25 | ||
27 | 26 | @Callable(i) | |
28 | 27 | func withdraw (amount) = { | |
29 | 28 | let currentKey = toBase58String(i.caller.bytes) | |
30 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
31 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
29 | + | let currentAmount = match getInteger(this, currentKey) { | |
32 | 30 | case a: Int => | |
33 | 31 | a | |
34 | 32 | case _ => | |
35 | 33 | 0 | |
36 | 34 | } | |
37 | 35 | let newAmount = (currentAmount - amount) | |
38 | 36 | if ((0 > amount)) | |
39 | 37 | then throw("Can't withdraw negative amount") | |
40 | 38 | else if ((0 > newAmount)) | |
41 | 39 | then throw("Not enough balance") | |
42 | - | else ScriptResult(WriteSet([DataEntry(xxxInvestorBalance, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
43 | - | } | |
44 | - | ||
45 | - | ||
46 | - | ||
47 | - | @Callable(i) | |
48 | - | func getFunds (amount) = { | |
49 | - | let quorum = 2 | |
50 | - | let currentKey = toBase58String(i.caller.bytes) | |
51 | - | let xxxStartupFund = ((currentKey + "_") + "sf") | |
52 | - | let xxxStartupVotes = ((currentKey + "_") + "sv") | |
53 | - | let currentAmount = match getInteger(this, xxxStartupFund) { | |
54 | - | case a: Int => | |
55 | - | a | |
56 | - | case _ => | |
57 | - | 0 | |
58 | - | } | |
59 | - | let totalVotes = match getInteger(this, xxxStartupVotes) { | |
60 | - | case a: Int => | |
61 | - | a | |
62 | - | case _ => | |
63 | - | 0 | |
64 | - | } | |
65 | - | let newAmount = (currentAmount - amount) | |
66 | - | if ((0 > amount)) | |
67 | - | then throw("Can't withdraw negative amount") | |
68 | - | else if ((0 > newAmount)) | |
69 | - | then throw("Not enough balance") | |
70 | - | else if ((quorum > totalVotes)) | |
71 | - | then throw("Not enough votes. At least 2 votes required!") | |
72 | - | else ScriptResult(WriteSet([DataEntry(xxxStartupFund, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
73 | - | } | |
74 | - | ||
75 | - | ||
76 | - | ||
77 | - | @Callable(i) | |
78 | - | func vote (amount,address) = { | |
79 | - | let currentKey = toBase58String(i.caller.bytes) | |
80 | - | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
81 | - | let xxxStartupFund = ((address + "_") + "sf") | |
82 | - | let xxxStartupVotes = ((address + "_") + "sv") | |
83 | - | let flagKey = ((address + "_") + currentKey) | |
84 | - | let flag = match getInteger(this, flagKey) { | |
85 | - | case a: Int => | |
86 | - | a | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
91 | - | case a: Int => | |
92 | - | a | |
93 | - | case _ => | |
94 | - | 0 | |
95 | - | } | |
96 | - | let currentVotes = match getInteger(this, xxxStartupVotes) { | |
97 | - | case a: Int => | |
98 | - | a | |
99 | - | case _ => | |
100 | - | 0 | |
101 | - | } | |
102 | - | let currentFund = match getInteger(this, xxxStartupFund) { | |
103 | - | case a: Int => | |
104 | - | a | |
105 | - | case _ => | |
106 | - | 0 | |
107 | - | } | |
108 | - | if ((0 >= amount)) | |
109 | - | then throw("Can't withdraw negative amount") | |
110 | - | else if ((amount > currentAmount)) | |
111 | - | then throw("Not enough balance!") | |
112 | - | else if ((flag > 0)) | |
113 | - | then throw("Only one vote per project is possible!") | |
114 | - | else WriteSet([DataEntry(xxxInvestorBalance, (currentAmount - amount)), DataEntry(xxxStartupVotes, (currentVotes + 1)), DataEntry(flagKey, 1), DataEntry(xxxStartupFund, (currentFund + amount))]) | |
40 | + | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
115 | 41 | } | |
116 | 42 | ||
117 | 43 |
github/deemru/w8io/169f3d6 39.30 ms ◑![]()