tx · GpntBDFEn2bhLp1nd9sN6bcCfkDFuJuQFVn2u2zQYTQx 3MwDmiM4CWFpGc8a5L16zwtwWjhbSNVCEph: -0.01000000 Waves 2019.08.29 15:15 [652489] smart account 3MwDmiM4CWFpGc8a5L16zwtwWjhbSNVCEph > SELF 0.00000000 Waves
{ "type": 13, "id": "GpntBDFEn2bhLp1nd9sN6bcCfkDFuJuQFVn2u2zQYTQx", "fee": 1000000, "feeAssetId": null, "timestamp": 1567081003104, "version": 1, "sender": "3MwDmiM4CWFpGc8a5L16zwtwWjhbSNVCEph", "senderPublicKey": "3DXWGbbag3PhPEkqaYFTU8zxy5fYHA9ishEg8nHZtugi", "proofs": [ "kU7JtB45NKNsS9mCagFBBkYrTCKZz7iRXjuv6c98dfHmuViTNJwRgv1y8BVL3DHZtydFD1nQQNh6mdPQb4qF3FB" ], "script": "base64:AAIDAAAAAAAAAAcIARIDCgEIAAAABwAAAAAGbWF4RmVlAAAAAAAAD0JAAAAAAAltaW5BbW91bnQJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAEWNvbmZpZ19taW5fYW1vdW50AAAAAA5hY2NlcHRCZXRVbnRpbAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwIAAAAQY29uZmlnX2JldF91bnRpbAAAAAAMYWNjZXB0QXNzZXRzCQAETAAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAOY29uZmlnX2Fzc2V0XzEJAARMAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAA5jb25maWdfYXNzZXRfMgUAAAADbmlsAQAAAAhyZXBheUZlZQAAAAUAAAABaQAAAAJ3cwAAAAdhZGRyZXNzAAAABmFtb3VudAAAAAVhc3NldAMJAABmAAAAAggFAAAAAWkAAAADZmVlBQAAAAZtYXhGZWUJAAACAAAAAQIAAAAWdW5yZWFzb25hYmxlIGxhcmdlIGZlZQMJAQAAAAIhPQAAAAIIBQAAAAFpAAAACmZlZ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pdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxiZXRSZXN1bHRLZXkCAAAACGFjY2VwdGVkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxiZXRBbW91bnRLZXkJAABkAAAAAgkBAAAADWdldEludERlZmF1bHQAAAACBQAAAAxiZXRBbW91bnRLZXkAAAAAAAAAAAAFAAAABmFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAARYmV0VG90YWxBbW91bnRLZXkJAABkAAAAAgkBAAAADWdldEludERlZmF1bHQAAAACBQAAABFiZXRUb3RhbEFtb3VudEtleQAAAAAAAAAAAAUAAAAGYW1vdW50BQAAAANuaWwIBQAAAANpbnYAAAAGY2FsbGVyAAAAAAAAAAAABQAAAAR1bml0CQEAAAAIcmVwYXlGZWUAAAAFBQAAAANpbnYJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADGJldFJlc3VsdEtleQIAAAAIcmV0dXJuZWQFAAAAA25pbAgFAAAABnR4RGF0YQAAAAZzZW5kZXIFAAAABmFtb3VudAgFAAAABnR4RGF0YQAAAAdhc3NldElkAAAAAHPnYWA=", "chainId": 84, "height": 652489, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let maxFee = 1000000 | |
5 | + | ||
6 | + | let minAmount = getIntegerValue(this, "config_min_amount") | |
7 | + | ||
8 | + | let acceptBetUntil = getIntegerValue(this, "config_bet_until") | |
9 | + | ||
10 | + | let acceptAssets = [getString(this, "config_asset_1"), getString(this, "config_asset_2")] | |
11 | + | ||
12 | + | func repayFee (i,ws,address,amount,asset) = if ((i.fee > maxFee)) | |
13 | + | then throw("unreasonable large fee") | |
14 | + | else if ((i.feeAssetId != unit)) | |
15 | + | then throw("fee must be in WAVES") | |
16 | + | else ScriptResult(ws, TransferSet([ScriptTransfer(i.caller, i.fee, unit), ScriptTransfer(address, amount, asset)])) | |
17 | + | ||
18 | + | ||
19 | + | func assetMnemonic (assetId) = match assetId { | |
20 | + | case u: Unit => | |
21 | + | "WAVES" | |
22 | + | case b: ByteVector => | |
23 | + | toBase58String(b) | |
24 | + | case _ => | |
25 | + | throw() | |
26 | + | } | |
27 | + | ||
28 | + | ||
29 | + | func getIntDefault (key,default) = match getInteger(this, key) { | |
30 | + | case i: Int => | |
31 | + | i | |
32 | + | case _ => | |
33 | + | default | |
34 | + | } | |
35 | + | ||
36 | + | ||
37 | + | @Callable(inv) | |
38 | + | func registerBetTx (tx) = { | |
39 | + | let txData = extract(transferTransactionById(fromBase58String(tx))) | |
40 | + | let owner = toBase58String(txData.sender.bytes) | |
41 | + | let asset = assetMnemonic(txData.assetId) | |
42 | + | let amount = txData.amount | |
43 | + | let txTimestamp = extract(blockInfoByHeight(extract(transactionHeightById(fromBase58String(tx))))).timestamp | |
44 | + | let betAmountKey = (((("bet_" + owner) + "_") + asset) + "_amount") | |
45 | + | let betTotalAmountKey = (("bet_total_" + asset) + "_amount") | |
46 | + | let betResultKey = (("tx_" + tx) + "_result") | |
47 | + | if ((txData.recipient != this)) | |
48 | + | then throw("invalid destination") | |
49 | + | else if (if ((asset != acceptAssets[0])) | |
50 | + | then (asset != acceptAssets[1]) | |
51 | + | else false) | |
52 | + | then throw("asset not accepted") | |
53 | + | else if (isDefined(getInteger(this, betResultKey))) | |
54 | + | then throw("tx already registered") | |
55 | + | else if ((minAmount > amount)) | |
56 | + | then throw(("min amount is " + toString(minAmount))) | |
57 | + | else if ((acceptBetUntil > txTimestamp)) | |
58 | + | then repayFee(inv, WriteSet([DataEntry(betResultKey, "accepted"), DataEntry(betAmountKey, (getIntDefault(betAmountKey, 0) + amount)), DataEntry(betTotalAmountKey, (getIntDefault(betTotalAmountKey, 0) + amount))]), inv.caller, 0, unit) | |
59 | + | else repayFee(inv, WriteSet([DataEntry(betResultKey, "returned")]), txData.sender, amount, txData.assetId) | |
60 | + | } | |
61 | + | ||
62 | + |
github/deemru/w8io/026f985 20.80 ms ◑