tx · E8HzhmX6gT8ikkWCo1GU8PNzmTgnYumZdpeXmZRQmQAF 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves 2022.11.13 15:01 [2315328] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "E8HzhmX6gT8ikkWCo1GU8PNzmTgnYumZdpeXmZRQmQAF", "fee": 1000000, "feeAssetId": null, "timestamp": 1668340929701, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "3SPqpfF66ZsqzCPrnCh74tFheonQCZwt7n4FtPqoUmzCrcnACLoD3heK6ft9tCqjaKYepHZjxTbnf3asKA5qA3Go" ], "script": "base64:BgIGCAISABIABQAMa1VzZXJQYXltZW50AgdQYXltZW50AARrV29uAgNXb24ACXNlcGFyYXRvcgIBXwEJcmFuZG9taXplAgVieXRlcwVyYW5nZQQEaGFzaAkA9wMBBQVieXRlcwQFaW5kZXgJALEJAQUEaGFzaAkAagIFBWluZGV4BQVyYW5nZQEIY291bnRpbmcBBWJ5dGVzBAVjb3VudAkBCXJhbmRvbWl6ZQIFBWJ5dGVzAAoDCQBnAgUFY291bnQAAwcGAgFpAQtwYXJzZVN0cnVjdAADCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgpPbmx5IG93bmVyBAx3aW5uZXJTdHJ1Y3QJAQhjb3VudGluZwEIBQFpDXRyYW5zYWN0aW9uSWQJAMwIAgkBDEJvb2xlYW5FbnRyeQIJAKwCAgkArAICCQCsAgIFBGtXb24FCXNlcGFyYXRvcgkApQgBCAUBaQZjYWxsZXIJAKQDAQkBCXJhbmRvbWl6ZQIIBQFpDXRyYW5zYWN0aW9uSWQA6AcFDHdpbm5lclN0cnVjdAkAzAgCCQEMQm9vbGVhbkVudHJ5AgUEa1dvbgUMd2lubmVyU3RydWN0BQNuaWwBaQEJc3RhcnRHYW1lAAQGYW1vdW50CQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdW5pdAkAAgECDFBheSBpbiB3YXZlcwMJAGYCBQZhbW91bnQACgkAAgECD1RvbyBtdWNoIGFtb3VudAQNbnVsbEluaXRTdG9yZQkA/AcEBQR0aGlzAgtwYXJzZVN0cnVjdAUDbmlsBQNuaWwDCQAAAgUNbnVsbEluaXRTdG9yZQUNbnVsbEluaXRTdG9yZQQDd29uCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJsIAgUEdGhpcwUEa1dvbgISU3RvcmFnZSByZWFkIGVycm9yAwUDd29uCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgkAaAIFBmFtb3VudAACBQR1bml0BQNuaWwFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgA6xAXo", "height": 2315328, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 48xskAHzutcnA19wWcGHp2UFaSoH54ia5DxEcd8sGZLn Next: AyYiw9Ubx4nVpk6A5d3LVvR1fnZHu88VapxMrtZPotsH Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let kUserPayment = "Payment" | |
5 | + | ||
6 | + | let kWon = "Won" | |
7 | + | ||
4 | 8 | let separator = "_" | |
5 | 9 | ||
6 | - | let kBuy = "buy" | |
10 | + | func randomize (bytes,range) = { | |
11 | + | let hash = sha256(bytes) | |
12 | + | let index = toInt(hash) | |
13 | + | (index % range) | |
14 | + | } | |
7 | 15 | ||
8 | - | let kSell = "sell" | |
9 | 16 | ||
10 | - | let kPrice = "price" | |
11 | - | ||
12 | - | func isNft (assetId) = match assetInfo(assetId) { | |
13 | - | case token: Asset => | |
14 | - | if (if ((token.decimals == 0)) | |
15 | - | then (token.quantity == 1) | |
16 | - | else false) | |
17 | - | then (token.reissuable == false) | |
18 | - | else false | |
19 | - | case _ => | |
20 | - | false | |
21 | - | } | |
17 | + | func counting (bytes) = { | |
18 | + | let count = randomize(bytes, 10) | |
19 | + | if ((count >= 3)) | |
20 | + | then false | |
21 | + | else true | |
22 | + | } | |
22 | 23 | ||
23 | 24 | ||
24 | 25 | @Callable(i) | |
25 | - | func issueNft (name,meta) = { | |
26 | - | let newToken = Issue(name, meta, 1, 0, false) | |
27 | - | let issueId = calculateAssetId(newToken) | |
28 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
29 | - | } | |
26 | + | func parseStruct () = if ((i.caller != this)) | |
27 | + | then throw("Only owner") | |
28 | + | else { | |
29 | + | let winnerStruct = counting(i.transactionId) | |
30 | + | [BooleanEntry((((kWon + separator) + toString(i.caller)) + toString(randomize(i.transactionId, 1000))), winnerStruct), BooleanEntry(kWon, winnerStruct)] | |
31 | + | } | |
30 | 32 | ||
31 | 33 | ||
32 | 34 | ||
33 | 35 | @Callable(i) | |
34 | - | func buyNFT (nftID) = { | |
35 | - | let assetId = fromBase58String(nftID) | |
36 | + | func startGame () = { | |
36 | 37 | let amount = value(i.payments[0].amount) | |
37 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
38 | - | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
39 | 38 | if ((i.payments[0].assetId != unit)) | |
40 | 39 | then throw("Pay in waves") | |
41 | - | else if ((parseIntValue(price) > amount)) | |
42 | - | then throw("Invalid payment") | |
43 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
44 | - | } | |
45 | - | ||
46 | - | ||
47 | - | ||
48 | - | @Callable(i) | |
49 | - | func sellNFT (price) = { | |
50 | - | let $t013981483 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
51 | - | let token0 = $t013981483._1 | |
52 | - | let amount0 = $t013981483._2 | |
53 | - | if (!(isNft(token0))) | |
54 | - | then throw("Token is not NFT") | |
55 | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
40 | + | else if ((amount > 10)) | |
41 | + | then throw("Too much amount") | |
42 | + | else { | |
43 | + | let nullInitStore = invoke(this, "parseStruct", nil, nil) | |
44 | + | if ((nullInitStore == nullInitStore)) | |
45 | + | then { | |
46 | + | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") | |
47 | + | if (won) | |
48 | + | then [ScriptTransfer(i.caller, (amount * 2), unit)] | |
49 | + | else nil | |
50 | + | } | |
51 | + | else throw("Strict value is not equal to itself.") | |
52 | + | } | |
56 | 53 | } | |
57 | 54 | ||
58 | 55 |
github/deemru/w8io/026f985 23.41 ms ◑