tx · BUkATxQA4GqH7itNNGhY8V4HnggxEkofvX1uAa8KFxpe 3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx: -1.00900000 Waves 2022.04.06 23:03 [1997160] smart account 3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx > SELF 0.00000000 Waves
{ "type": 13, "id": "BUkATxQA4GqH7itNNGhY8V4HnggxEkofvX1uAa8KFxpe", "fee": 100900000, "feeAssetId": null, "timestamp": 1649275074286, "version": 2, "chainId": 84, "sender": "3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx", "senderPublicKey": "B37Jiw5CgfjxqxYgkAGeJpTmiCa4Cb6a9mh9fynZppFR", "proofs": [ "63P266gZBMpenj6gheJVXYn9Tso7zAwH8E3Xxg6C75TnN8h4DkkJSe9k61SjkTbtzYwHDgXrVMMEP4jpHLvfP1nh" ], "script": "base64:AAIFAAAAAAAAAAoIAhIAEgQKAgIBAAAAAAAAAAIAAAABaQEAAAAQY3JlYXRlTXV0aHVUb2tlbgAAAAADCQAAAAAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAEdGhpcwQAAAAFaXNzdWUJAARCAAAABQIAAAAFTVVUSFUCAAAAF0EgdGVzdCB0b2tlbiBieSBLLk11dGh1AAAAAAAAAYagAAAAAAAAAAACBgQAAAACaWQJAAQ4AAAAAQUAAAAFaXNzdWUJAAUUAAAAAgkABEwAAAACBQAAAAVpc3N1ZQkABEwAAAACCQEAAAALQmluYXJ5RW50cnkAAAACAgAAAAJpZAUAAAACaWQFAAAAA25pbAUAAAAEdW5pdAkAAAIAAAABAgAAABRUb2tlbiBhbHJlYWR5IGlzc3VlZAAAAAFpAQAAAApnaXZlVG9rZW5zAAAAAgAAAAdhZGRyZXNzAAAABmFtb3VudAQAAAAHYXNzZXRJRAQAAAAHJG1hdGNoMAkABBwAAAACBQAAAAR0aGlzAgAAAAJpZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAAACaWQFAAAAByRtYXRjaDAFAAAAAmlkCQAAAgAAAAECAAAAFENhbid0IGZpbmQgQXNzZXN0IElEAwMJAAAAAAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAR0aGlzCQAAZwAAAAIJAAPwAAAAAgUAAAAEdGhpcwUAAAAHYXNzZXRJRAUAAAAGYW1vdW50BwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAAlgAAAABBQAAAAdhZGRyZXNzBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAB0FkZHJlc3MAAAABBQAAAAdhZGRyZXNzBQAAAAZhbW91bnQFAAAAB2Fzc2V0SUQFAAAAA25pbAkAAAIAAAABAgAAACBDYW4ndCBjYWxsIG9yIG5vdCBlbm91Z2ggYmFsYW5jZQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5rbWLrg==", "height": 1997160, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3LJEkDYjQP13K4hbaG8schQnWPWigTSTCukiDpHmiftJ Next: Eje9D2U45MC68NKGQFGEKxGRziai73Ak6ejdi76erDsm Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let owner = Address(base58'3N2i7ygFVfQLEoupDNpBT7FLcjh4Sb38wm9') | |
5 | - | ||
6 | - | let players = nil | |
7 | - | ||
8 | - | func randomizer (inv) = { | |
9 | - | let rand = (inv.transactionId + inv.callerPublicKey) | |
10 | - | sha256(rand) | |
11 | - | } | |
12 | - | ||
13 | - | ||
14 | - | func addPlayersToList (i) = (players :+ i.caller) | |
15 | 4 | ||
16 | 5 | ||
17 | 6 | @Callable(i) | |
18 | - | func enter () = { | |
19 | - | let a = addPlayersToList(i) | |
20 | - | [ScriptTransfer(this, i.payments[0].amount, unit)] | |
21 | - | } | |
7 | + | func createMuthuToken () = if ((i.caller == this)) | |
8 | + | then { | |
9 | + | let issue = Issue("MUTHU", "A test token by K.Muthu", 100000, 2, true) | |
10 | + | let id = calculateAssetId(issue) | |
11 | + | $Tuple2([issue, BinaryEntry("id", id)], unit) | |
12 | + | } | |
13 | + | else throw("Token already issued") | |
22 | 14 | ||
23 | 15 | ||
24 | 16 | ||
25 | 17 | @Callable(i) | |
26 | - | func pickWinner () = if ((i.caller == owner)) | |
27 | - | then { | |
28 | - | let numberOfPlayers = size(players) | |
29 | - | let rand = toInt(randomizer(i)) | |
30 | - | let selectedPlayer = players[(rand % numberOfPlayers)] | |
31 | - | [ScriptTransfer(selectedPlayer, ((i.payments[0].amount * 80) / 100), unit), ScriptTransfer(owner, ((i.payments[0].amount * 20) / 100), unit)] | |
32 | - | } | |
33 | - | else throw("You havent permissions") | |
18 | + | func giveTokens (address,amount) = { | |
19 | + | let assetID = match getBinary(this, "id") { | |
20 | + | case id: ByteVector => | |
21 | + | id | |
22 | + | case _ => | |
23 | + | throw("Can't find Assest ID") | |
24 | + | } | |
25 | + | if (if ((i.caller == this)) | |
26 | + | then (assetBalance(this, assetID) >= amount) | |
27 | + | else false) | |
28 | + | then [IntegerEntry(toBase58String(address), amount), ScriptTransfer(Address(address), amount, assetID)] | |
29 | + | else throw("Can't call or not enough balance") | |
30 | + | } | |
34 | 31 | ||
35 | 32 | ||
36 | 33 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let owner = Address(base58'3N2i7ygFVfQLEoupDNpBT7FLcjh4Sb38wm9') | |
5 | - | ||
6 | - | let players = nil | |
7 | - | ||
8 | - | func randomizer (inv) = { | |
9 | - | let rand = (inv.transactionId + inv.callerPublicKey) | |
10 | - | sha256(rand) | |
11 | - | } | |
12 | - | ||
13 | - | ||
14 | - | func addPlayersToList (i) = (players :+ i.caller) | |
15 | 4 | ||
16 | 5 | ||
17 | 6 | @Callable(i) | |
18 | - | func enter () = { | |
19 | - | let a = addPlayersToList(i) | |
20 | - | [ScriptTransfer(this, i.payments[0].amount, unit)] | |
21 | - | } | |
7 | + | func createMuthuToken () = if ((i.caller == this)) | |
8 | + | then { | |
9 | + | let issue = Issue("MUTHU", "A test token by K.Muthu", 100000, 2, true) | |
10 | + | let id = calculateAssetId(issue) | |
11 | + | $Tuple2([issue, BinaryEntry("id", id)], unit) | |
12 | + | } | |
13 | + | else throw("Token already issued") | |
22 | 14 | ||
23 | 15 | ||
24 | 16 | ||
25 | 17 | @Callable(i) | |
26 | - | func pickWinner () = if ((i.caller == owner)) | |
27 | - | then { | |
28 | - | let numberOfPlayers = size(players) | |
29 | - | let rand = toInt(randomizer(i)) | |
30 | - | let selectedPlayer = players[(rand % numberOfPlayers)] | |
31 | - | [ScriptTransfer(selectedPlayer, ((i.payments[0].amount * 80) / 100), unit), ScriptTransfer(owner, ((i.payments[0].amount * 20) / 100), unit)] | |
32 | - | } | |
33 | - | else throw("You havent permissions") | |
18 | + | func giveTokens (address,amount) = { | |
19 | + | let assetID = match getBinary(this, "id") { | |
20 | + | case id: ByteVector => | |
21 | + | id | |
22 | + | case _ => | |
23 | + | throw("Can't find Assest ID") | |
24 | + | } | |
25 | + | if (if ((i.caller == this)) | |
26 | + | then (assetBalance(this, assetID) >= amount) | |
27 | + | else false) | |
28 | + | then [IntegerEntry(toBase58String(address), amount), ScriptTransfer(Address(address), amount, assetID)] | |
29 | + | else throw("Can't call or not enough balance") | |
30 | + | } | |
34 | 31 | ||
35 | 32 | ||
36 | 33 | @Verifier(tx) | |
37 | 34 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
38 | 35 |
github/deemru/w8io/026f985 31.48 ms ◑