tx · A23sR2sNWSQDrFEB3io77bLk2Tp2sMkJp3119GQDj5go
3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC: -0.01400000 Waves
2020.04.10 13:05 [948102] smart account 3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC > SELF 0.00000000 Waves
{
"type": 13,
"id": "A23sR2sNWSQDrFEB3io77bLk2Tp2sMkJp3119GQDj5go",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1586513145060,
"version": 1,
"sender": "3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC",
"senderPublicKey": "BNrrKkZSXXCbcCtXLT3VMQnSAJt2jt8TLnZWaB5US3Ci",
"proofs": [
"2qGsECRsaVLHYBC8Tvj8iXBDgSYKbopPEPvS8xsQxTpBR4Vsfmb6i94dFKB4H7LBxAF57sQVjCLyVkbaxntTLrLX"
],
"script": "base64:AAIDAAAAAAAAAAoIARIAEgQKAgEIAAAABAAAAAAEdXNkbgEAAAAgImQ/Hr5gRukRahMT3KYz/hZ+B/l36bPyFfyZSSowCjcBAAAACmdldEJhbGFuY2UAAAACAAAAB2FkZHJlc3MAAAAHYXNzZXRJZAQAAAABYgkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgUAAAAHYWRkcmVzcwIAAAABXwUAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAUAAAABYgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAF0BQAAAAckbWF0Y2gwBQAAAAF0AAAAAAAAAAAAAQAAAApnZXRBc3NldElkAAAAAQAAAAdhc3NldElkBAAAAAckbWF0Y2gwBQAAAAdhc3NldElkAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFiBQAAAAckbWF0Y2gwCQACWAAAAAEFAAAAAWICAAAABVdBVkVTAQAAAA5hc3NldElkVG9CeXRlcwAAAAEAAAAHYXNzZXRJZAMJAAAAAAAAAgUAAAAHYXNzZXRJZAIAAAA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3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGYW1vdW50CQEAAAAOYXNzZXRJZFRvQnl0ZXMAAAABBQAAAAdhc3NldElkBQAAAANuaWwJAAACAAAAAQkAASwAAAACAgAAABBZb3VyIGJhbGFuY2UgaXMgCQABpAAAAAEFAAAAA2JhbAAAAACIdwrz",
"chainId": 84,
"height": 948102,
"spentComplexity": 0
}
View: original | compacted
Prev: 8SALX1ha7bkpGdEABvRuym5YaAmEnCKypqCV94DEYzer
Next: D1pfZeBq4bqTMMABvr8SAsC3RfyNwiakJC9Je2fHgeDf
Diff:
Old | New | | Differences |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let usdn = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC' |
---|
5 | 5 | | |
---|
6 | | - | func getBalance (address) = { |
---|
7 | | - | let b = getInteger(this, address) |
---|
| 6 | + | func getBalance (address,assetId) = { |
---|
| 7 | + | let b = getInteger(this, ((address + "_") + assetId)) |
---|
8 | 8 | | match b { |
---|
9 | 9 | | case t: Int => |
---|
10 | 10 | | t |
---|
|
14 | 14 | | } |
---|
15 | 15 | | |
---|
16 | 16 | | |
---|
| 17 | + | func getAssetId (assetId) = match assetId { |
---|
| 18 | + | case b: ByteVector => |
---|
| 19 | + | toBase58String(b) |
---|
| 20 | + | case _ => |
---|
| 21 | + | "WAVES" |
---|
| 22 | + | } |
---|
| 23 | + | |
---|
| 24 | + | |
---|
| 25 | + | func assetIdToBytes (assetId) = if ((assetId == "WAVES")) |
---|
| 26 | + | then unit |
---|
| 27 | + | else fromBase58String(assetId) |
---|
| 28 | + | |
---|
| 29 | + | |
---|
17 | 30 | | @Callable(i) |
---|
18 | 31 | | func deposit () = { |
---|
19 | 32 | | let address = toBase58String(i.caller.bytes) |
---|
20 | | - | let bal = getBalance(address) |
---|
21 | 33 | | let payment = extract(i.payment) |
---|
22 | | - | if ((payment.assetId == usdn)) |
---|
23 | | - | then ScriptResult(WriteSet([DataEntry(address, (bal + payment.amount))]), TransferSet(nil)) |
---|
24 | | - | else throw("Should be USDN") |
---|
| 34 | + | let assetId = getAssetId(payment.assetId) |
---|
| 35 | + | let bal = getBalance(address, assetId) |
---|
| 36 | + | ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal + payment.amount))]), TransferSet(nil)) |
---|
25 | 37 | | } |
---|
26 | 38 | | |
---|
27 | 39 | | |
---|
28 | 40 | | |
---|
29 | 41 | | @Callable(i) |
---|
30 | | - | func withdraw (amount) = { |
---|
| 42 | + | func withdraw (amount,assetId) = { |
---|
31 | 43 | | let address = toBase58String(i.caller.bytes) |
---|
32 | | - | let bal = getBalance(address) |
---|
| 44 | + | let bal = getBalance(address, assetId) |
---|
33 | 45 | | if ((bal >= amount)) |
---|
34 | | - | then ScriptResult(WriteSet([DataEntry(address, (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, usdn)])) |
---|
| 46 | + | then ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, assetIdToBytes(assetId))])) |
---|
35 | 47 | | else throw(("Your balance is " + toString(bal))) |
---|
36 | 48 | | } |
---|
37 | 49 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let usdn = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC' |
---|
5 | 5 | | |
---|
6 | | - | func getBalance (address) = { |
---|
7 | | - | let b = getInteger(this, address) |
---|
| 6 | + | func getBalance (address,assetId) = { |
---|
| 7 | + | let b = getInteger(this, ((address + "_") + assetId)) |
---|
8 | 8 | | match b { |
---|
9 | 9 | | case t: Int => |
---|
10 | 10 | | t |
---|
11 | 11 | | case _ => |
---|
12 | 12 | | 0 |
---|
13 | 13 | | } |
---|
14 | 14 | | } |
---|
15 | 15 | | |
---|
16 | 16 | | |
---|
| 17 | + | func getAssetId (assetId) = match assetId { |
---|
| 18 | + | case b: ByteVector => |
---|
| 19 | + | toBase58String(b) |
---|
| 20 | + | case _ => |
---|
| 21 | + | "WAVES" |
---|
| 22 | + | } |
---|
| 23 | + | |
---|
| 24 | + | |
---|
| 25 | + | func assetIdToBytes (assetId) = if ((assetId == "WAVES")) |
---|
| 26 | + | then unit |
---|
| 27 | + | else fromBase58String(assetId) |
---|
| 28 | + | |
---|
| 29 | + | |
---|
17 | 30 | | @Callable(i) |
---|
18 | 31 | | func deposit () = { |
---|
19 | 32 | | let address = toBase58String(i.caller.bytes) |
---|
20 | | - | let bal = getBalance(address) |
---|
21 | 33 | | let payment = extract(i.payment) |
---|
22 | | - | if ((payment.assetId == usdn)) |
---|
23 | | - | then ScriptResult(WriteSet([DataEntry(address, (bal + payment.amount))]), TransferSet(nil)) |
---|
24 | | - | else throw("Should be USDN") |
---|
| 34 | + | let assetId = getAssetId(payment.assetId) |
---|
| 35 | + | let bal = getBalance(address, assetId) |
---|
| 36 | + | ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal + payment.amount))]), TransferSet(nil)) |
---|
25 | 37 | | } |
---|
26 | 38 | | |
---|
27 | 39 | | |
---|
28 | 40 | | |
---|
29 | 41 | | @Callable(i) |
---|
30 | | - | func withdraw (amount) = { |
---|
| 42 | + | func withdraw (amount,assetId) = { |
---|
31 | 43 | | let address = toBase58String(i.caller.bytes) |
---|
32 | | - | let bal = getBalance(address) |
---|
| 44 | + | let bal = getBalance(address, assetId) |
---|
33 | 45 | | if ((bal >= amount)) |
---|
34 | | - | then ScriptResult(WriteSet([DataEntry(address, (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, usdn)])) |
---|
| 46 | + | then ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, assetIdToBytes(assetId))])) |
---|
35 | 47 | | else throw(("Your balance is " + toString(bal))) |
---|
36 | 48 | | } |
---|
37 | 49 | | |
---|
38 | 50 | | |
---|