1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let par7Id = base58'3Janbh2r7ZQjiUM3sWVswVGHWyQB2TPxm348QvuX5v6c' |
---|
5 | | - | |
---|
6 | | - | @Callable(i) |
---|
7 | | - | func par7deposit () = { |
---|
8 | | - | let pmt = extract(i.payment) |
---|
9 | | - | if ((pmt.assetId != par7Id)) |
---|
10 | | - | then throw("PAR7 only at the moment") |
---|
11 | | - | 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)]) |
---|
21 | | - | } |
---|
22 | | - | } |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | @Callable(i) |
---|
27 | | - | func par7withdraw (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 |
---|
34 | | - | } |
---|
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 enough balance") |
---|
40 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, par7Id)])) |
---|
41 | | - | } |
---|
42 | | - | |
---|
43 | | - | |
---|
44 | | - | @Verifier(tx) |
---|
45 | | - | func verify () = match tx { |
---|
46 | | - | case s: SetScriptTransaction => |
---|
47 | | - | true |
---|
48 | | - | case d: DataTransaction => |
---|
49 | | - | true |
---|
50 | | - | case _ => |
---|
51 | | - | false |
---|
52 | | - | } |
---|
53 | | - | |
---|
| 1 | + | {-# STDLIB_VERSION 2 #-} |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let pKey0 = base58'HiVUGpeJgwXhMuFBLeQ8qzZ2QRVK7R9pGeDhs2qPTPHD' |
---|
| 4 | + | sigVerify(tx.bodyBytes, tx.proofs[0], pKey0) |
---|