tx · 37qHXXHTSec5oXip1bCnb2WCqjeYnFawNaPwWN3eWtgN

3N1SNsqhyGDYAA7b8ZTgwhD7QHGJMT4nBJX:  -0.01000000 Waves

2022.04.03 16:08 [1992449] smart account 3N1SNsqhyGDYAA7b8ZTgwhD7QHGJMT4nBJX > SELF 0.00000000 Waves

{ "type": 13, "id": "37qHXXHTSec5oXip1bCnb2WCqjeYnFawNaPwWN3eWtgN", "fee": 1000000, "feeAssetId": null, "timestamp": 1648991292819, "version": 2, "chainId": 84, "sender": "3N1SNsqhyGDYAA7b8ZTgwhD7QHGJMT4nBJX", "senderPublicKey": "B6nC1bV4M26PtCHchSuaoTMtRz8Kp4ywEkErAYbfJ8NY", "proofs": [ "5Ba7YJ5SUvosV398wiTcubRZgFGjWBi5AwikmZakgHwuoAbyyJhqmrypwnUm4XZtKewCJUa2jT3Kv11RxnXxuUtY" ], "script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAAQAAAAABW93bmVyCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUjFZ7fOjZY90m9pn8ViGu955KF8V0o4vQAAAAAAdwbGF5ZXJzBQAAAANuaWwBAAAACnJhbmRvbWl6ZXIAAAABAAAAA2ludgQAAAAEcmFuZAkAAMsAAAACCAUAAAADaW52AAAADXRyYW5zYWN0aW9uSWQIBQAAAANpbnYAAAAPY2FsbGVyUHVibGljS2V5BQAAAARyYW5kAQAAABBhZGRQbGF5ZXJzVG9MaXN0AAAAAQAAAAFpCQAETQAAAAIFAAAAB3BsYXllcnMIBQAAAAFpAAAABmNhbGxlcgAAAAMAAAABaQEAAAAKZ2V0UGxheWVycwAAAAAFAAAAB3BsYXllcnMAAAABaQEAAAAFZW50ZXIAAAAABAAAAAFhCQEAAAAQYWRkUGxheWVyc1RvTGlzdAAAAAEFAAAAAWkEAAAADXBsYXllckFkZHJlc3MIBQAAAAFpAAAABmNhbGxlcgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAR0aGlzCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAAFpAQAAAApwaWNrV2lubmVyAAAAAAMJAAAAAAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAR0aGlzBAAAAA9udW1iZXJPZlBsYXllcnMJAAGQAAAAAQUAAAAHcGxheWVycwQAAAAEcmFuZAkABLEAAAABCQEAAAAKcmFuZG9taXplcgAAAAEFAAAAAWkEAAAADnNlbGVjdGVkUGxheWVyCQABkQAAAAIFAAAAB3BsYXllcnMJAABqAAAAAgUAAAAEcmFuZAUAAAAPbnVtYmVyT2ZQbGF5ZXJzCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAADnNlbGVjdGVkUGxheWVyCQAAaQAAAAIJAABoAAAAAggJAAPvAAAAAQUAAAAEdGhpcwAAAAlhdmFpbGFibGUAAAAAAAAAAFAAAAAAAAAAAGQFAAAABHVuaXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAFb3duZXIJAABpAAAAAgkAAGgAAAACCAkAA+8AAAABBQAAAAR0aGlzAAAACWF2YWlsYWJsZQAAAAAAAAAAFAAAAAAAAAAAZAUAAAAEdW5pdAUAAAADbmlsCQAAAgAAAAECAAAAFllvdSBoYXZlbnQgcGVybWlzc2lvbnMAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleVewglU=", "height": 1992449, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BAAbNPXiubUtakxy8Zf7FpCJoStP1Jv6dpy3BhxUJxxK Next: none Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 3 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let owner = Address(base58'3N2i7ygFVfQLEoupDNpBT7FLcjh4Sb38wm9')
55
6-let marketingAccount = Address(base58'3N1SNsqhyGDYAA7b8ZTgwhD7QHGJMT4nBJX')
7-
8-let commissionPercentage = 20
9-
10-let entryAmount = 5
11-
12-let denominator = 100
13-
14-let currentPricePool = 0
15-
166 let players = nil
177
8+func randomizer (inv) = {
9+ let rand = (inv.transactionId + inv.callerPublicKey)
10+ rand
11+ }
12+
13+
14+func addPlayersToList (i) = (players :+ i.caller)
15+
16+
17+@Callable(i)
1818 func getPlayers () = players
19+
1920
2021
2122 @Callable(i)
2223 func enter () = {
23- let callerAddress = toBase58String(i.caller.bytes)
24- let payment = extract(i.payment)
25- TransferSet([ScriptTransfer(this, payment.amount, unit)])
24+ let a = addPlayersToList(i)
25+ let playerAddress = i.caller
26+[ScriptTransfer(this, i.payments[0].amount, unit)]
2627 }
2728
2829
2930
3031 @Callable(i)
31-func pickWinner () = WriteSet(nil)
32+func pickWinner () = if ((i.caller == this))
33+ then {
34+ let numberOfPlayers = size(players)
35+ let rand = toInt(randomizer(i))
36+ let selectedPlayer = players[(rand % numberOfPlayers)]
37+[ScriptTransfer(selectedPlayer, ((wavesBalance(this).available * 80) / 100), unit), ScriptTransfer(owner, ((wavesBalance(this).available * 20) / 100), unit)]
38+ }
39+ else throw("You havent permissions")
3240
3341
3442 @Verifier(tx)
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 3 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let owner = Address(base58'3N2i7ygFVfQLEoupDNpBT7FLcjh4Sb38wm9')
55
6-let marketingAccount = Address(base58'3N1SNsqhyGDYAA7b8ZTgwhD7QHGJMT4nBJX')
7-
8-let commissionPercentage = 20
9-
10-let entryAmount = 5
11-
12-let denominator = 100
13-
14-let currentPricePool = 0
15-
166 let players = nil
177
8+func randomizer (inv) = {
9+ let rand = (inv.transactionId + inv.callerPublicKey)
10+ rand
11+ }
12+
13+
14+func addPlayersToList (i) = (players :+ i.caller)
15+
16+
17+@Callable(i)
1818 func getPlayers () = players
19+
1920
2021
2122 @Callable(i)
2223 func enter () = {
23- let callerAddress = toBase58String(i.caller.bytes)
24- let payment = extract(i.payment)
25- TransferSet([ScriptTransfer(this, payment.amount, unit)])
24+ let a = addPlayersToList(i)
25+ let playerAddress = i.caller
26+[ScriptTransfer(this, i.payments[0].amount, unit)]
2627 }
2728
2829
2930
3031 @Callable(i)
31-func pickWinner () = WriteSet(nil)
32+func pickWinner () = if ((i.caller == this))
33+ then {
34+ let numberOfPlayers = size(players)
35+ let rand = toInt(randomizer(i))
36+ let selectedPlayer = players[(rand % numberOfPlayers)]
37+[ScriptTransfer(selectedPlayer, ((wavesBalance(this).available * 80) / 100), unit), ScriptTransfer(owner, ((wavesBalance(this).available * 20) / 100), unit)]
38+ }
39+ else throw("You havent permissions")
3240
3341
3442 @Verifier(tx)
3543 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
3644

github/deemru/w8io/169f3d6 
27.47 ms