tx · ERheEv3VCmgDW2FywKcbF7xZjJvKgSz39EBTrn6psFMK 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua: -0.01000000 Waves 2023.11.02 15:43 [2825728] smart account 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua > SELF 0.00000000 Waves
{ "type": 13, "id": "ERheEv3VCmgDW2FywKcbF7xZjJvKgSz39EBTrn6psFMK", "fee": 1000000, "feeAssetId": null, "timestamp": 1698929036218, "version": 2, "chainId": 84, "sender": "3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua", "senderPublicKey": "JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P", "proofs": [ "2zChsvWqfmhtYuHEypnTR2hJk5fWtrU2K4QTndaCgVxxm1tM9zrQNvjvgVMGQ2XthLKSDSNpDx2GDSzzJJrnyqg4" ], "script": "base64:BgIXCAISAwoBAhIICgYICAEBAQESBAoCCAgJAANTRVACAl9fAQZuZnRLZXkBBW5mdElkCQC5CQIJAMwIAgIDbmZ0CQDMCAIJANgEAQUFbmZ0SWQFA25pbAUDU0VQARVuZnRUeXBlRGVzY3JpcHRpb25LZXkBCW5mdFR5cGVJZAkAuQkCCQDMCAICCG5mdF90eXBlCQDMCAIFCW5mdFR5cGVJZAUDbmlsBQNTRVABBnNldE5mdAQFbmZ0SWQJbmZ0VHlwZUlkBmhlYWx0aAZkYW1hZ2UJAQtTdHJpbmdFbnRyeQIJAQZuZnRLZXkBBQVuZnRJZAkAuQkCCQDMCAIFCW5mdFR5cGVJZAkAzAgCCQCkAwEFBmhlYWx0aAkAzAgCCQCkAwEFBmRhbWFnZQUDbmlsBQNTRVABFWdldE5mdFR5cGVEZXNjcmlwdGlvbgEJbmZ0VHlwZUlkBAtzYXZlZFN0cmluZwkAtQkCBAckbWF0Y2gwCQCdCAIFBHRoaXMJARVuZnRUeXBlRGVzY3JpcHRpb25LZXkBBQluZnRUeXBlSWQDCQABAgUHJG1hdGNoMAIGU3Rya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lwdGlvbgJfMwgFD3R5cGVEZXNjcmlwdGlvbgJfMgQGZGFtYWdlCQBkAggFD3R5cGVEZXNjcmlwdGlvbgJfNAkAagIJALEJAQgFB2RhbWFnZVQCXzEJAGUCCAUPdHlwZURlc2NyaXB0aW9uAl81CAUPdHlwZURlc2NyaXB0aW9uAl80BAtkZXNjcmlwdGlvbgkArAICCQCsAgIJAKwCAgkArAICAhB7ImluaXRIZWFsdGgiOiAiCQCkAwEFBmhlYWx0aAIRIiwgImluaXREYW1hZ2UiOiAJAKQDAQUGZGFtYWdlAgF9BAVhc3NldAkAwggFBQluZnRUeXBlSWQFC2Rlc2NyaXB0aW9uAAEAAAcEB2Fzc2V0SWQJALgIAQUFYXNzZXQJAJQKAgkAzAgCCQEGc2V0TmZ0BAUHYXNzZXRJZAUJbmZ0VHlwZUlkBQZoZWFsdGgFBmRhbWFnZQkAzAgCBQVhc3NldAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQEFdmFsdWUBCQCmCAEFAnRvAAEFB2Fzc2V0SWQFA25pbAkA2AQBBQdhc3NldElkAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleUTc1eI=", "height": 2825728, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 9JyGvi2cajgrAiCdvb3QXZUuLy6BFWFozeTSyjm4oswr Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | func nftKey (nftId) = makeString(["nft", toBase58String(nftId)], SEP) | |
7 | + | ||
8 | + | ||
9 | + | func nftTypeDescriptionKey (nftTypeId) = makeString(["nft_type", nftTypeId], SEP) | |
10 | + | ||
11 | + | ||
12 | + | func setNft (nftId,nftTypeId,health,damage) = StringEntry(nftKey(nftId), makeString([nftTypeId, toString(health), toString(damage)], SEP)) | |
13 | + | ||
14 | + | ||
15 | + | func getNftTypeDescription (nftTypeId) = { | |
16 | + | let savedString = split( match getString(this, nftTypeDescriptionKey(nftTypeId)) { | |
17 | + | case s: String => | |
18 | + | s | |
19 | + | case _ => | |
20 | + | throw("nft type not found") | |
21 | + | }, SEP) | |
22 | + | $Tuple5(savedString[0], parseIntValue(savedString[1]), parseIntValue(savedString[2]), parseIntValue(savedString[3]), parseIntValue(savedString[4])) | |
23 | + | } | |
24 | + | ||
25 | + | ||
26 | + | func randomizer (inv,salt) = { | |
27 | + | let rand = (((((salt + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
28 | + | $Tuple2(sha256(rand), rand) | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | func internalGetNft (address) = match getString(this, nftKey(address)) { | |
33 | + | case s: String => | |
34 | + | let splittedString = split(s, SEP) | |
35 | + | $Tuple3(splittedString[0], parseIntValue(splittedString[1]), parseIntValue(splittedString[2])) | |
36 | + | case _ => | |
37 | + | nil | |
38 | + | } | |
39 | + | ||
40 | + | ||
41 | + | func map (accum,nextNftAddress) = match internalGetNft(nextNftAddress) { | |
42 | + | case s: (String, Int, Int) => | |
43 | + | s :: accum | |
44 | + | case _ => | |
45 | + | accum | |
46 | + | } | |
47 | + | ||
48 | + | ||
49 | + | func getNfts (address) = $Tuple2(nil, { | |
50 | + | let $l = address | |
51 | + | let $s = size($l) | |
52 | + | let $acc0 = nil | |
53 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
54 | + | then $a | |
55 | + | else map($a, $l[$i]) | |
56 | + | ||
57 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
58 | + | then $a | |
59 | + | else throw("List size exceeds 5") | |
60 | + | ||
61 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
62 | + | }) | |
63 | + | ||
64 | + | ||
65 | + | @Callable(i) | |
66 | + | func getNft (address) = $Tuple2(nil, internalGetNft(address)) | |
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | @Callable(i) | |
71 | + | func setNftTypeDescription (nftTypeId,img,minHealth,maxHealth,minDamage,maxDamage) = [StringEntry(nftTypeDescriptionKey(nftTypeId), makeString([img, toString(minHealth), toString(maxHealth), toString(minDamage), toString(maxDamage)], SEP))] | |
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | @Callable(i) | |
76 | + | func mint (nftTypeId,to) = { | |
77 | + | let typeDescription = getNftTypeDescription(nftTypeId) | |
78 | + | let healthT = randomizer(i, base58'') | |
79 | + | let damageT = randomizer(i, healthT._2) | |
80 | + | let health = (typeDescription._3 + (toInt(healthT._1) % (typeDescription._3 - typeDescription._2))) | |
81 | + | let damage = (typeDescription._4 + (toInt(damageT._1) % (typeDescription._5 - typeDescription._4))) | |
82 | + | let description = (((("{\"initHealth\": \"" + toString(health)) + "\", \"initDamage\": ") + toString(damage)) + "}") | |
83 | + | let asset = Issue(nftTypeId, description, 1, 0, false) | |
84 | + | let assetId = calculateAssetId(asset) | |
85 | + | $Tuple2([setNft(assetId, nftTypeId, health, damage), asset, ScriptTransfer(value(addressFromString(to)), 1, assetId)], toBase58String(assetId)) | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | @Verifier(tx) | |
90 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
91 | + |
github/deemru/w8io/026f985 523.75 ms ◑