2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | |
---|
5 | | - | |
---|
6 | | - | @Callable(i) |
---|
7 | | - | func deposit () = { |
---|
8 | | - | let payment = value(i.payments) |
---|
9 | | - | if (if ((size(payment) > 1)) |
---|
10 | | - | then true |
---|
11 | | - | else isDefined(payment[0].assetId)) |
---|
12 | | - | then throw("You can only one WAVES deposit at a time") |
---|
13 | | - | else { |
---|
14 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
15 | | - | let currentAmount = valueOrElse(getInteger(this, currentKey), 0) |
---|
16 | | - | let newAmount = (currentAmount + payment[0].amount) |
---|
17 | | - | [IntegerEntry(currentKey, newAmount)] |
---|
18 | | - | } |
---|
19 | | - | } |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | @Callable(i) |
---|
24 | | - | func withdraw (amount) = { |
---|
25 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
26 | | - | let currentAmount = valueOrElse(getInteger(this, currentKey), 0) |
---|
27 | | - | let newAmount = (currentAmount - amount) |
---|
28 | | - | if ((0 > amount)) |
---|
29 | | - | then throw("Cannot withdraw negative amount") |
---|
30 | | - | else if ((0 > newAmount)) |
---|
31 | | - | then throw("Not enough balance") |
---|
32 | | - | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)] |
---|
33 | | - | } |
---|
34 | | - | |
---|
35 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let firstUser = base58'CPfirstUserPk' |
---|
| 4 | + | let secondUser = base58'CPsecondUserPk' |
---|
| 5 | + | let thirdUser = base58'CPthirdUserPk' |
---|
| 6 | + | let firstSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], firstUser)) |
---|
| 7 | + | then 1 |
---|
| 8 | + | else 0 |
---|
| 9 | + | let secondSigned = if (sigVerify(tx.bodyBytes, tx.proofs[1], secondUser)) |
---|
| 10 | + | then 1 |
---|
| 11 | + | else 0 |
---|
| 12 | + | let thirdSigned = if (sigVerify(tx.bodyBytes, tx.proofs[2], thirdUser)) |
---|
| 13 | + | then 1 |
---|
| 14 | + | else 0 |
---|
| 15 | + | (((firstSigned + secondSigned) + thirdSigned) >= 2) |
---|