tx · Gxwr7992DN3szipMygap4yLxdiBPHAtLETwL4s11yB61
3NBRpCwD2XJLYjTRfXWfqU6WNvQ4W54USaL: -0.00100000 Waves
2023.05.17 10:28 [2581654] smart account 3NBRpCwD2XJLYjTRfXWfqU6WNvQ4W54USaL > SELF 0.00000000 Waves
{
"type": 13,
"id": "Gxwr7992DN3szipMygap4yLxdiBPHAtLETwL4s11yB61",
"fee": 100000,
"feeAssetId": null,
"timestamp": 1684308437986,
"version": 2,
"chainId": 84,
"sender": "3NBRpCwD2XJLYjTRfXWfqU6WNvQ4W54USaL",
"senderPublicKey": "E9tHJcvY3yRVSet84AJTX73d828n6rPYHFdezjjJa8Jf",
"proofs": [
"E7jTxegRTuf91Nxmekv5p3UFx6LAt32SrZVfz2ece3gzfc5dYUJtSfJuh1nhRoSntuwZbB47hNvB2JwJD6HyjHg"
],
"script": "base64:BgIJCAISABIDCgEBAAIBaQEHZGVwb3NpdAAEB3BheW1lbnQJAQV2YWx1ZQEIBQFpCHBheW1lbnRzAwMJAGYCCQCQAwEFB3BheW1lbnQAAQYJAQlpc0RlZmluZWQBCAkAkQMCBQdwYXltZW50AAAHYXNzZXRJZAkAAgECKFlvdSBjYW4gb25seSBvbmUgV0FWRVMgZGVwb3NpdCBhdCBhIHRpbWUECmN1cnJlbnRLZXkJANgEAQgIBQFpBmNhbGxlcgVieXRlcwQNY3VycmVudEFtb3VudAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQpjdXJyZW50S2V5AAAECW5ld0Ftb3VudAkAZAIFDWN1cnJlbnRBbW91bnQICQCRAwIFB3BheW1lbnQAAAZhbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIFCmN1cnJlbnRLZXkFCW5ld0Ftb3VudAUDbmlsAWkBCHdpdGhkcmF3AQZhbW91bnQECmN1cnJlbnRLZXkJANgEAQgIBQFpBmNhbGxlcgVieXRlcwQNY3VycmVudEFtb3VudAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQpjdXJyZW50S2V5AAAECW5ld0Ftb3VudAkAZQIFDWN1cnJlbnRBbW91bnQFBmFtb3VudAMJAGYCAAAFBmFtb3VudAkAAgECH0Nhbm5vdCB3aXRoZHJhdyBuZWdhdGl2ZSBhbW91bnQDCQBmAgAABQluZXdBbW91bnQJAAIBAhJOb3QgZW5vdWdoIGJhbGFuY2UJAMwIAgkBDEludGVnZXJFbnRyeQIFCmN1cnJlbnRLZXkFCW5ld0Ftb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFBmFtb3VudAUEdW5pdAUDbmlsAQJ0eAEGdmVyaWZ5AAQHJG1hdGNoMAUCdHgDCQABAgUHJG1hdGNoMAIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EC3NldFNjcmlwdFR4BQckbWF0Y2gwBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleUmsbSU=",
"height": 2581654,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 7WhEgqsKzyd8DzLPqT8qdA2q26VqmXhhw2xD4ZsAc63e
Next: none
Diff:
Old | New | | Differences |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | | - | func helloWorld (name) = [StringEntry("answer", ("Hello World! Hello, " + name))] |
---|
| 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 | + | } |
---|
8 | 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 | + | |
---|
| 36 | + | @Verifier(tx) |
---|
| 37 | + | func verify () = match tx { |
---|
| 38 | + | case setScriptTx: SetScriptTransaction => |
---|
| 39 | + | false |
---|
| 40 | + | case _ => |
---|
| 41 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
| 42 | + | } |
---|
9 | 43 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 6 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | | - | func helloWorld (name) = [StringEntry("answer", ("Hello World! Hello, " + name))] |
---|
| 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 | + | } |
---|
8 | 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 | + | |
---|
| 36 | + | @Verifier(tx) |
---|
| 37 | + | func verify () = match tx { |
---|
| 38 | + | case setScriptTx: SetScriptTransaction => |
---|
| 39 | + | false |
---|
| 40 | + | case _ => |
---|
| 41 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
| 42 | + | } |
---|
9 | 43 | | |
---|