tx · 3t1Bv3SgAPk3KKwVReh9VoPV5JMae6xuSUrCYFr4NDX2
3MqRnEd83AoPWjTCHP2PVpFpWg6KbBPCJyo: -0.01400000 Waves
2019.09.08 12:18 [666907] smart account 3MqRnEd83AoPWjTCHP2PVpFpWg6KbBPCJyo > SELF 0.00000000 Waves
{
"type": 13,
"id": "3t1Bv3SgAPk3KKwVReh9VoPV5JMae6xuSUrCYFr4NDX2",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1567934265076,
"version": 1,
"sender": "3MqRnEd83AoPWjTCHP2PVpFpWg6KbBPCJyo",
"senderPublicKey": "C1VF5w6S6GzcSydWsAbL2czedDrjFAPUeyZ5HknvisxJ",
"proofs": [
"u1PzpRQtNXSdeG9SBnKt3Wu1BXDH7LARCXWnqMUUmmKuGVF7KAEuTd8CsVnBNfE2srea9dNNFtwjxTJd7x2dYGo"
],
"script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkCQAAAgAAAAECAAAAIWNhbiBob2RsIHdhdmVzIG9ubHkgYXQgdGhlIG1vbWVudAQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAAFbXlhZHIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM05BY29lV2RVVFduOGNzWEpQRzQ3djFGanRqY2ZxeGI1dHUEAAAADGNvcnJlY3R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VyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAABTXu68",
"chainId": 84,
"height": 666907,
"spentComplexity": 0
}
View: original | compacted
Prev: GVovjFkysZtDKgmhB13UePQL5LQ3nxn7xzr96EV29BFD
Next: 2yQnbe3fbfAQbtphApncNjqY7cJWy9efZEQ5CULosYa4
Diff:
Old | New | | Differences |
---|
17 | 17 | | 0 |
---|
18 | 18 | | } |
---|
19 | 19 | | let myadr = addressFromStringValue("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu") |
---|
20 | | - | let correctPrice = getInteger(myadr, "waves_btc_8") |
---|
| 20 | + | let correctPrice = match getInteger(myadr, "waves_btc_8") { |
---|
| 21 | + | case a: Int => |
---|
| 22 | + | a |
---|
| 23 | + | case _ => |
---|
| 24 | + | 0 |
---|
| 25 | + | } |
---|
21 | 26 | | let newAmount = (currentAmount + pmt.amount) |
---|
22 | 27 | | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
23 | 28 | | } |
---|
| 29 | + | } |
---|
| 30 | + | |
---|
| 31 | + | |
---|
| 32 | + | |
---|
| 33 | + | @Callable(i) |
---|
| 34 | + | func withdraw (amount) = { |
---|
| 35 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
| 36 | + | let currentAmount = match getInteger(this, currentKey) { |
---|
| 37 | + | case a: Int => |
---|
| 38 | + | a |
---|
| 39 | + | case _ => |
---|
| 40 | + | 0 |
---|
| 41 | + | } |
---|
| 42 | + | let newAmount = (currentAmount - amount) |
---|
| 43 | + | if ((0 > amount)) |
---|
| 44 | + | then throw("Can't withdraw negative amount") |
---|
| 45 | + | else if ((0 > newAmount)) |
---|
| 46 | + | then throw("Not enough balance") |
---|
| 47 | + | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
24 | 48 | | } |
---|
25 | 49 | | |
---|
26 | 50 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | 7 | | func deposit () = { |
---|
8 | 8 | | let pmt = extract(i.payment) |
---|
9 | 9 | | if (isDefined(pmt.assetId)) |
---|
10 | 10 | | then throw("can hodl waves only at the moment") |
---|
11 | 11 | | else { |
---|
12 | 12 | | let currentKey = toBase58String(i.caller.bytes) |
---|
13 | 13 | | let currentAmount = match getInteger(this, currentKey) { |
---|
14 | 14 | | case a: Int => |
---|
15 | 15 | | a |
---|
16 | 16 | | case _ => |
---|
17 | 17 | | 0 |
---|
18 | 18 | | } |
---|
19 | 19 | | let myadr = addressFromStringValue("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu") |
---|
20 | | - | let correctPrice = getInteger(myadr, "waves_btc_8") |
---|
| 20 | + | let correctPrice = match getInteger(myadr, "waves_btc_8") { |
---|
| 21 | + | case a: Int => |
---|
| 22 | + | a |
---|
| 23 | + | case _ => |
---|
| 24 | + | 0 |
---|
| 25 | + | } |
---|
21 | 26 | | let newAmount = (currentAmount + pmt.amount) |
---|
22 | 27 | | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
23 | 28 | | } |
---|
| 29 | + | } |
---|
| 30 | + | |
---|
| 31 | + | |
---|
| 32 | + | |
---|
| 33 | + | @Callable(i) |
---|
| 34 | + | func withdraw (amount) = { |
---|
| 35 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
| 36 | + | let currentAmount = match getInteger(this, currentKey) { |
---|
| 37 | + | case a: Int => |
---|
| 38 | + | a |
---|
| 39 | + | case _ => |
---|
| 40 | + | 0 |
---|
| 41 | + | } |
---|
| 42 | + | let newAmount = (currentAmount - amount) |
---|
| 43 | + | if ((0 > amount)) |
---|
| 44 | + | then throw("Can't withdraw negative amount") |
---|
| 45 | + | else if ((0 > newAmount)) |
---|
| 46 | + | then throw("Not enough balance") |
---|
| 47 | + | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
24 | 48 | | } |
---|
25 | 49 | | |
---|
26 | 50 | | |
---|