tx · GQ8BF9HRgumTUQposQo6vjVxNYUTokgvaneefvNRY3A1
3MrD29Em3UVB6KUouximkPkYJPUAtL8jqpn: -0.01400000 Waves
2021.05.25 15:54 [1541213] smart account 3MrD29Em3UVB6KUouximkPkYJPUAtL8jqpn > SELF 0.00000000 Waves
{
"type": 13,
"id": "GQ8BF9HRgumTUQposQo6vjVxNYUTokgvaneefvNRY3A1",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1621947248223,
"version": 2,
"chainId": 84,
"sender": "3MrD29Em3UVB6KUouximkPkYJPUAtL8jqpn",
"senderPublicKey": "56eNaKVmDQUA4CeqQiK9bWnhNsm9iFLFtrdtGNCQfkTu",
"proofs": [
"4k8sQXa5XVALqhuhRS3C17RP1JCWBRxx98oxCm84PTTW8hhT4F22jSGnVin3jq2JVzCzDCrZtHKYAhWFZwabwqew"
],
"script": "base64:AAIEAAAAAAAAABcIAhIDCgEIEgMKAQESAwoBARIECgIIAQAAAAsBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPZ2V0S2V5VXNlckVtYWlsAAAAAQAAAAR1c2VyCQABLAAAAAIJAAEsAAAAAgIAAAAFdXNlcl8FAAAABHVzZXICAAAABl9lbWFpbAEAAAARZ2V0VmFsdWVVc2VyRW1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JhbGFuY2UAAAAABQAAAAhxdWFudGl0eQUAAAADbmlsAAAAAWkBAAAADXRyYW5zZmVyVG9rZW4AAAACAAAACXJlY2lwaWVudAAAAAZhbW91bnQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5M+0zDQ==",
"height": 1541213,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 3Qh4YrUJUCnyPAQKRcffoCLWzHqQuXWKKi7U7bPR4fJt
Next: none
Diff:
Old | New | | Differences |
---|
1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
| 1 | + | {-# STDLIB_VERSION 4 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let nyanToken = base58'FYeHd8VsE6SWQBzMFYDPbV7xjFdBMJt5gnCZCSiYyoHE' |
---|
| 4 | + | func getNumberByKey (key) = { |
---|
| 5 | + | let number = match getInteger(this, key) { |
---|
| 6 | + | case a: Int => |
---|
| 7 | + | a |
---|
| 8 | + | case _ => |
---|
| 9 | + | 0 |
---|
| 10 | + | } |
---|
| 11 | + | number |
---|
| 12 | + | } |
---|
| 13 | + | |
---|
| 14 | + | |
---|
| 15 | + | let NONE = "none" |
---|
| 16 | + | |
---|
| 17 | + | func getStringByKey (key) = { |
---|
| 18 | + | let string = match getString(this, key) { |
---|
| 19 | + | case a: String => |
---|
| 20 | + | a |
---|
| 21 | + | case _ => |
---|
| 22 | + | NONE |
---|
| 23 | + | } |
---|
| 24 | + | string |
---|
| 25 | + | } |
---|
| 26 | + | |
---|
| 27 | + | |
---|
| 28 | + | func getKeyUserEmail (user) = (("user_" + user) + "_email") |
---|
| 29 | + | |
---|
| 30 | + | |
---|
| 31 | + | func getValueUserEmail (user) = getStringByKey(getKeyUserEmail(user)) |
---|
| 32 | + | |
---|
| 33 | + | |
---|
| 34 | + | func getKeyUserBalance (user) = (("user_" + user) + "balance") |
---|
| 35 | + | |
---|
| 36 | + | |
---|
| 37 | + | func getValueUserBalance (user) = getNumberByKey(getKeyUserBalance(user)) |
---|
| 38 | + | |
---|
| 39 | + | |
---|
| 40 | + | func getKeyDAppAssetId () = "dApp_assetId" |
---|
| 41 | + | |
---|
| 42 | + | |
---|
| 43 | + | func getValueDAppAssetId () = getStringByKey(getKeyDAppAssetId()) |
---|
| 44 | + | |
---|
| 45 | + | |
---|
| 46 | + | func getKeyDAppBalance () = "dApp_assetId" |
---|
| 47 | + | |
---|
| 48 | + | |
---|
| 49 | + | func getValueDAppAmount () = getStringByKey(getKeyDAppBalance()) |
---|
| 50 | + | |
---|
5 | 51 | | |
---|
6 | 52 | | @Callable(i) |
---|
7 | | - | func deposit () = { |
---|
8 | | - | let pmt = extract(i.payment) |
---|
9 | | - | if ((pmt.assetId != nyanToken)) |
---|
10 | | - | then throw("NYAN-13 tokens only supports") |
---|
| 53 | + | func signUp (email) = { |
---|
| 54 | + | let currentUserAddress = toBase58String(i.caller.bytes) |
---|
| 55 | + | let currentUserEmail = getValueUserEmail(currentUserAddress) |
---|
| 56 | + | if ((currentUserEmail != NONE)) |
---|
| 57 | + | then throw("user is already registered") |
---|
| 58 | + | else [StringEntry(getKeyUserEmail(currentUserAddress), email), IntegerEntry(getKeyUserBalance(currentUserAddress), 0)] |
---|
| 59 | + | } |
---|
| 60 | + | |
---|
| 61 | + | |
---|
| 62 | + | |
---|
| 63 | + | @Callable(i) |
---|
| 64 | + | func issueToken (quantity) = { |
---|
| 65 | + | let dAppAssetId = getValueDAppAssetId() |
---|
| 66 | + | if ((dAppAssetId != NONE)) |
---|
| 67 | + | then throw("token has already been issued") |
---|
11 | 68 | | else { |
---|
12 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
13 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
14 | | - | case a: Int => |
---|
15 | | - | a |
---|
16 | | - | case _ => |
---|
17 | | - | 0 |
---|
18 | | - | } |
---|
19 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
20 | | - | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
| 69 | + | let asset = Issue("NYAN-25", "NYAN-25 token", quantity, 0, true) |
---|
| 70 | + | let assetId = calculateAssetId(asset) |
---|
| 71 | + | [asset, StringEntry(getKeyDAppAssetId(), toBase58String(assetId)), IntegerEntry(getKeyDAppBalance(), quantity)] |
---|
21 | 72 | | } |
---|
22 | 73 | | } |
---|
23 | 74 | | |
---|
24 | 75 | | |
---|
25 | 76 | | |
---|
26 | 77 | | @Callable(i) |
---|
27 | | - | func withdraw (amount) = { |
---|
28 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
29 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
30 | | - | case a: Int => |
---|
31 | | - | a |
---|
32 | | - | case _ => |
---|
33 | | - | 0 |
---|
| 78 | + | func reissueToken (quantity) = { |
---|
| 79 | + | let dAppAssetId = getValueDAppAssetId() |
---|
| 80 | + | if ((dAppAssetId == NONE)) |
---|
| 81 | + | then throw("token has not been issued") |
---|
| 82 | + | else [Reissue(fromBase58String(dAppAssetId), quantity, true), IntegerEntry(getKeyDAppBalance(), quantity)] |
---|
34 | 83 | | } |
---|
35 | | - | let newAmount = (currentAmount - amount) |
---|
36 | | - | if ((0 > amount)) |
---|
37 | | - | then throw("can't withdraw negative amount") |
---|
38 | | - | else if ((0 > newAmount)) |
---|
39 | | - | then throw("not enoung balance") |
---|
40 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, nyanToken)])) |
---|
41 | | - | } |
---|
| 84 | + | |
---|
| 85 | + | |
---|
| 86 | + | |
---|
| 87 | + | @Callable(i) |
---|
| 88 | + | func transferToken (recipient,amount) = nil |
---|
42 | 89 | | |
---|
43 | 90 | | |
---|
44 | 91 | | @Verifier(tx) |
---|
Full:
Old | New | | Differences |
---|
1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
| 1 | + | {-# STDLIB_VERSION 4 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let nyanToken = base58'FYeHd8VsE6SWQBzMFYDPbV7xjFdBMJt5gnCZCSiYyoHE' |
---|
| 4 | + | func getNumberByKey (key) = { |
---|
| 5 | + | let number = match getInteger(this, key) { |
---|
| 6 | + | case a: Int => |
---|
| 7 | + | a |
---|
| 8 | + | case _ => |
---|
| 9 | + | 0 |
---|
| 10 | + | } |
---|
| 11 | + | number |
---|
| 12 | + | } |
---|
| 13 | + | |
---|
| 14 | + | |
---|
| 15 | + | let NONE = "none" |
---|
| 16 | + | |
---|
| 17 | + | func getStringByKey (key) = { |
---|
| 18 | + | let string = match getString(this, key) { |
---|
| 19 | + | case a: String => |
---|
| 20 | + | a |
---|
| 21 | + | case _ => |
---|
| 22 | + | NONE |
---|
| 23 | + | } |
---|
| 24 | + | string |
---|
| 25 | + | } |
---|
| 26 | + | |
---|
| 27 | + | |
---|
| 28 | + | func getKeyUserEmail (user) = (("user_" + user) + "_email") |
---|
| 29 | + | |
---|
| 30 | + | |
---|
| 31 | + | func getValueUserEmail (user) = getStringByKey(getKeyUserEmail(user)) |
---|
| 32 | + | |
---|
| 33 | + | |
---|
| 34 | + | func getKeyUserBalance (user) = (("user_" + user) + "balance") |
---|
| 35 | + | |
---|
| 36 | + | |
---|
| 37 | + | func getValueUserBalance (user) = getNumberByKey(getKeyUserBalance(user)) |
---|
| 38 | + | |
---|
| 39 | + | |
---|
| 40 | + | func getKeyDAppAssetId () = "dApp_assetId" |
---|
| 41 | + | |
---|
| 42 | + | |
---|
| 43 | + | func getValueDAppAssetId () = getStringByKey(getKeyDAppAssetId()) |
---|
| 44 | + | |
---|
| 45 | + | |
---|
| 46 | + | func getKeyDAppBalance () = "dApp_assetId" |
---|
| 47 | + | |
---|
| 48 | + | |
---|
| 49 | + | func getValueDAppAmount () = getStringByKey(getKeyDAppBalance()) |
---|
| 50 | + | |
---|
5 | 51 | | |
---|
6 | 52 | | @Callable(i) |
---|
7 | | - | func deposit () = { |
---|
8 | | - | let pmt = extract(i.payment) |
---|
9 | | - | if ((pmt.assetId != nyanToken)) |
---|
10 | | - | then throw("NYAN-13 tokens only supports") |
---|
| 53 | + | func signUp (email) = { |
---|
| 54 | + | let currentUserAddress = toBase58String(i.caller.bytes) |
---|
| 55 | + | let currentUserEmail = getValueUserEmail(currentUserAddress) |
---|
| 56 | + | if ((currentUserEmail != NONE)) |
---|
| 57 | + | then throw("user is already registered") |
---|
| 58 | + | else [StringEntry(getKeyUserEmail(currentUserAddress), email), IntegerEntry(getKeyUserBalance(currentUserAddress), 0)] |
---|
| 59 | + | } |
---|
| 60 | + | |
---|
| 61 | + | |
---|
| 62 | + | |
---|
| 63 | + | @Callable(i) |
---|
| 64 | + | func issueToken (quantity) = { |
---|
| 65 | + | let dAppAssetId = getValueDAppAssetId() |
---|
| 66 | + | if ((dAppAssetId != NONE)) |
---|
| 67 | + | then throw("token has already been issued") |
---|
11 | 68 | | else { |
---|
12 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
13 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
14 | | - | case a: Int => |
---|
15 | | - | a |
---|
16 | | - | case _ => |
---|
17 | | - | 0 |
---|
18 | | - | } |
---|
19 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
20 | | - | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
| 69 | + | let asset = Issue("NYAN-25", "NYAN-25 token", quantity, 0, true) |
---|
| 70 | + | let assetId = calculateAssetId(asset) |
---|
| 71 | + | [asset, StringEntry(getKeyDAppAssetId(), toBase58String(assetId)), IntegerEntry(getKeyDAppBalance(), quantity)] |
---|
21 | 72 | | } |
---|
22 | 73 | | } |
---|
23 | 74 | | |
---|
24 | 75 | | |
---|
25 | 76 | | |
---|
26 | 77 | | @Callable(i) |
---|
27 | | - | func withdraw (amount) = { |
---|
28 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
29 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
30 | | - | case a: Int => |
---|
31 | | - | a |
---|
32 | | - | case _ => |
---|
33 | | - | 0 |
---|
| 78 | + | func reissueToken (quantity) = { |
---|
| 79 | + | let dAppAssetId = getValueDAppAssetId() |
---|
| 80 | + | if ((dAppAssetId == NONE)) |
---|
| 81 | + | then throw("token has not been issued") |
---|
| 82 | + | else [Reissue(fromBase58String(dAppAssetId), quantity, true), IntegerEntry(getKeyDAppBalance(), quantity)] |
---|
34 | 83 | | } |
---|
35 | | - | let newAmount = (currentAmount - amount) |
---|
36 | | - | if ((0 > amount)) |
---|
37 | | - | then throw("can't withdraw negative amount") |
---|
38 | | - | else if ((0 > newAmount)) |
---|
39 | | - | then throw("not enoung balance") |
---|
40 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, nyanToken)])) |
---|
41 | | - | } |
---|
| 84 | + | |
---|
| 85 | + | |
---|
| 86 | + | |
---|
| 87 | + | @Callable(i) |
---|
| 88 | + | func transferToken (recipient,amount) = nil |
---|
42 | 89 | | |
---|
43 | 90 | | |
---|
44 | 91 | | @Verifier(tx) |
---|
45 | 92 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
46 | 93 | | |
---|