tx · EtkhWFrzZuxb17YVDmAQvJHkmgpD5PAssF82EpocfiG4 3N4i3G2EdWNjLewRyPASraLZDLU98iZqp5B: -0.01400000 Waves 2020.12.08 13:13 [1299546] smart account 3N4i3G2EdWNjLewRyPASraLZDLU98iZqp5B > SELF 0.00000000 Waves
{ "type": 13, "id": "EtkhWFrzZuxb17YVDmAQvJHkmgpD5PAssF82EpocfiG4", "fee": 1400000, "feeAssetId": null, "timestamp": 1607422464520, "version": 2, "chainId": 84, "sender": "3N4i3G2EdWNjLewRyPASraLZDLU98iZqp5B", "senderPublicKey": "837cMoxDMWe57Su67yzZSTmUoj7HkvcMiJw94P8WSG9m", "proofs": [ "4M1MEc6s1RAeLixonJVV7gPHxjGGErWCfxUd2w1PzTJwjcg1SJ1MULhxUfSfM4UU8Ev43r1oU4hcv72yeynQScAQ" ], "script": "base64:AAIEAAAAAAAAAAgIAhIECgIIAQAAAAkAAAAABE5PTkUCAAAABG5vbmUAAAAABkJBTk5FRAIAAAAGYmFubmVkAAAAAAZBQ1RJVkUCAAAABmFjdGl2ZQAAAAAGT1JBQ0xFAQAAABoBVGfPNPfYE6JADMFnaYFRYJmEtok/GnzMqQAAAAAHYXNzZXRJZAEAAAAgP1blgqUQx2mb30rk4VmM9mSw2pqcNceErdVRes5MxJcBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADXVzZXJTdGF0dXNLZXkAAAABAAAABG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keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXleqPWf", "height": 1299546, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GgGwUdS3bKLd9WqVwziK65qB9WzXgJW24c5eUci1iLpc Next: 6ipsUYeH3ZU2k4NTdu3bph4NyzrnT3wLcTxGJNLDJVrU Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | - | let | |
6 | + | let BANNED = "banned" | |
7 | 7 | ||
8 | - | @Callable(i) | |
9 | - | func deposit () = { | |
10 | - | let pmt = value(i.payments) | |
11 | - | if ((pmt[0].assetId != myAsset)) | |
12 | - | then throw("Wrong asset, required: 5GFY8QsKcrYr3ySRQCaJ7wRiY6fVfHTroYMBQw1mDvC6") | |
13 | - | else { | |
14 | - | let currentKey = toBase58String(i.caller.bytes) | |
15 | - | let currentAmount = match getInteger(this, currentKey) { | |
16 | - | case a: Int => | |
17 | - | a | |
18 | - | case _ => | |
19 | - | 0 | |
20 | - | } | |
21 | - | let newAmount = (currentAmount + pmt[0].amount) | |
22 | - | [IntegerEntry(currentKey, newAmount)] | |
23 | - | } | |
24 | - | } | |
8 | + | let ACTIVE = "active" | |
25 | 9 | ||
10 | + | let ORACLE = base58'3MyNybffEkHnXLZohq8NZ6LMcAciizFp8K2' | |
11 | + | ||
12 | + | let assetId = base58'5GFY8QsKcrYr3ySRQCaJ7wRiY6fVfHTroYMBQw1mDvC6' | |
13 | + | ||
14 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
15 | + | case a: Int => | |
16 | + | a | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func getStrByKey (key) = match getString(this, key) { | |
23 | + | case a: String => | |
24 | + | a | |
25 | + | case _ => | |
26 | + | 0 | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func userStatusKey (addr) = ("user_" + addr) | |
31 | + | ||
32 | + | ||
33 | + | func userStatusValue (addr) = match getString(this, userStatusKey(addr)) { | |
34 | + | case a: String => | |
35 | + | a | |
36 | + | case _ => | |
37 | + | NONE | |
38 | + | } | |
26 | 39 | ||
27 | 40 | ||
28 | 41 | @Callable(i) | |
29 | - | func withdraw (amount) = { | |
30 | - | let currentKey = toBase58String(i.caller.bytes) | |
31 | - | let currentAmount = match getInteger(this, currentKey) { | |
32 | - | case a: Int => | |
33 | - | a | |
34 | - | case _ => | |
35 | - | 0 | |
36 | - | } | |
37 | - | let newAmount = (currentAmount - amount) | |
38 | - | if ((0 > amount)) | |
39 | - | then throw("negative amount!") | |
40 | - | else if ((0 > newAmount)) | |
41 | - | then throw("not enough balance") | |
42 | - | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, myAsset)] | |
43 | - | } | |
42 | + | func addUser (addr,amount) = if ((i.caller.bytes == ORACLE)) | |
43 | + | then { | |
44 | + | let walletAddress = addressFromStringValue(addr) | |
45 | + | let userStatus = userStatusValue(addr) | |
46 | + | let minamount = 1 | |
47 | + | if ((minamount > amount)) | |
48 | + | then throw("amount is too low") | |
49 | + | else if ((userStatus == NONE)) | |
50 | + | then [StringEntry(userStatusKey(addr), ACTIVE), ScriptTransfer(walletAddress, amount, assetId)] | |
51 | + | else [ScriptTransfer(walletAddress, amount, assetId)] | |
52 | + | } | |
53 | + | else throw("forbidden") | |
44 | 54 | ||
45 | 55 | ||
46 | 56 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | - | let | |
6 | + | let BANNED = "banned" | |
7 | 7 | ||
8 | - | @Callable(i) | |
9 | - | func deposit () = { | |
10 | - | let pmt = value(i.payments) | |
11 | - | if ((pmt[0].assetId != myAsset)) | |
12 | - | then throw("Wrong asset, required: 5GFY8QsKcrYr3ySRQCaJ7wRiY6fVfHTroYMBQw1mDvC6") | |
13 | - | else { | |
14 | - | let currentKey = toBase58String(i.caller.bytes) | |
15 | - | let currentAmount = match getInteger(this, currentKey) { | |
16 | - | case a: Int => | |
17 | - | a | |
18 | - | case _ => | |
19 | - | 0 | |
20 | - | } | |
21 | - | let newAmount = (currentAmount + pmt[0].amount) | |
22 | - | [IntegerEntry(currentKey, newAmount)] | |
23 | - | } | |
24 | - | } | |
8 | + | let ACTIVE = "active" | |
25 | 9 | ||
10 | + | let ORACLE = base58'3MyNybffEkHnXLZohq8NZ6LMcAciizFp8K2' | |
11 | + | ||
12 | + | let assetId = base58'5GFY8QsKcrYr3ySRQCaJ7wRiY6fVfHTroYMBQw1mDvC6' | |
13 | + | ||
14 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
15 | + | case a: Int => | |
16 | + | a | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func getStrByKey (key) = match getString(this, key) { | |
23 | + | case a: String => | |
24 | + | a | |
25 | + | case _ => | |
26 | + | 0 | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func userStatusKey (addr) = ("user_" + addr) | |
31 | + | ||
32 | + | ||
33 | + | func userStatusValue (addr) = match getString(this, userStatusKey(addr)) { | |
34 | + | case a: String => | |
35 | + | a | |
36 | + | case _ => | |
37 | + | NONE | |
38 | + | } | |
26 | 39 | ||
27 | 40 | ||
28 | 41 | @Callable(i) | |
29 | - | func withdraw (amount) = { | |
30 | - | let currentKey = toBase58String(i.caller.bytes) | |
31 | - | let currentAmount = match getInteger(this, currentKey) { | |
32 | - | case a: Int => | |
33 | - | a | |
34 | - | case _ => | |
35 | - | 0 | |
36 | - | } | |
37 | - | let newAmount = (currentAmount - amount) | |
38 | - | if ((0 > amount)) | |
39 | - | then throw("negative amount!") | |
40 | - | else if ((0 > newAmount)) | |
41 | - | then throw("not enough balance") | |
42 | - | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, myAsset)] | |
43 | - | } | |
42 | + | func addUser (addr,amount) = if ((i.caller.bytes == ORACLE)) | |
43 | + | then { | |
44 | + | let walletAddress = addressFromStringValue(addr) | |
45 | + | let userStatus = userStatusValue(addr) | |
46 | + | let minamount = 1 | |
47 | + | if ((minamount > amount)) | |
48 | + | then throw("amount is too low") | |
49 | + | else if ((userStatus == NONE)) | |
50 | + | then [StringEntry(userStatusKey(addr), ACTIVE), ScriptTransfer(walletAddress, amount, assetId)] | |
51 | + | else [ScriptTransfer(walletAddress, amount, assetId)] | |
52 | + | } | |
53 | + | else throw("forbidden") | |
44 | 54 | ||
45 | 55 | ||
46 | 56 | @Verifier(tx) | |
47 | 57 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
48 | 58 |
github/deemru/w8io/169f3d6 34.48 ms ◑![]()