tx · PPVT3jaL1aNyyxxYSgxWPcvZtmkw73Yz1jdXFofTf7H 3Mz8aZoSQ1oqC4kBfA6Gx94edw2RNRMsa73: -0.01000000 Waves 2023.02.13 13:55 [2447748] smart account 3Mz8aZoSQ1oqC4kBfA6Gx94edw2RNRMsa73 > SELF 0.00000000 Waves
{ "type": 13, "id": "PPVT3jaL1aNyyxxYSgxWPcvZtmkw73Yz1jdXFofTf7H", "fee": 1000000, "feeAssetId": null, "timestamp": 1676285790234, "version": 2, "chainId": 84, "sender": "3Mz8aZoSQ1oqC4kBfA6Gx94edw2RNRMsa73", "senderPublicKey": "EJp3vJd3QL2izBZE187Ft6SJzWycrN8WhNZBw5FJqbux", "proofs": [ "4xmVjPyYUZL6VN5S6tvMNM2spqEgVjvbSvksiGrr24cAZrPxpHkcgQZTjL4zTTzWwJKLhZk8k6RhEmCM9bCnao1q" ], "script": "base64:BgIRCAISBgoECAgICBIDCgEBEgAMAAdrQ29tbW9uAgZjb21tb24ABWtSYXJlAgRyYXJlAAprTGVnZW5kYXJ5AglsZWdlbmRhcnkABmtQcmljZQIKcHJpY2VMZXZlcgAJc2VwYXJhdG9yAgF8AAljb3VudFJhcmUJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUFa1JhcmUAAAALY291bnRDb21tb24JAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUHa0NvbW1vbgAAAA5jb3VudExlZ2VuZGFyeQkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQprTGVnZW5kYXJ5AAAADGNvcnJlY3RQcmljZQkBEUBleHRyTmF0aXZlKDEwNTApAgUEdGhpcwUGa1ByaWNlAQlyYW5kb21pemUCBWJ5dGVzBXJhbmdlBARoYXNoCQD3AwEFBWJ5dGVzBAVpbmRleAkAsQkBBQRoYXNoCQBqAgUFaW5kZXgFBXJhbmdlARBpbmNyZW1lbnRDb3VudGVyAQRyYXJlAwkAAAIFBHJhcmUFB2tDb21tb24JAQxJbnRlZ2Vy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GcmFyaXR5CQEPY2FsY3VsYXRlUmFyaXR5AQgFAWkNdHJhbnNhY3Rpb25JZAQPaW5jcmVtZW50U3RydWN0CQEQaW5jcmVtZW50Q291bnRlcgEFBnJhcml0eQQIdG9rZW5LZXkJAKwCAgkArAICBQZyYXJpdHkFCXNlcGFyYXRvcgkApAMBCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFBnJhcml0eQAABAhhc3NldEtleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFBHRoaXMFCHRva2VuS2V5BQh0b2tlbktleQkAzAgCBQ9pbmNyZW1lbnRTdHJ1Y3QJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyAAEJANkEAQUIYXNzZXRLZXkJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICCQClCAEIBQFpBmNhbGxlcgUIdG9rZW5LZXkFCGFzc2V0S2V5BQNuaWwA/uxjpA==", "height": 2447748, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HTJhaWR3RwXkEVsmcxm5VGm3xi3DCvyLvzaTPah2QrNj Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION 5 #-} | |
2 | - | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | - | func getOwnerAddr () = { | |
4 | - | let owner = getString(this, "owner") | |
5 | - | if (!(isDefined(owner))) | |
6 | - | then throw("init first") | |
7 | - | else addressFromStringValue(value(owner)) | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let kCommon = "common" | |
5 | + | ||
6 | + | let kRare = "rare" | |
7 | + | ||
8 | + | let kLegendary = "legendary" | |
9 | + | ||
10 | + | let kPrice = "priceLever" | |
11 | + | ||
12 | + | let separator = "|" | |
13 | + | ||
14 | + | let countRare = valueOrElse(getInteger(this, kRare), 0) | |
15 | + | ||
16 | + | let countCommon = valueOrElse(getInteger(this, kCommon), 0) | |
17 | + | ||
18 | + | let countLegendary = valueOrElse(getInteger(this, kLegendary), 0) | |
19 | + | ||
20 | + | let correctPrice = getIntegerValue(this, kPrice) | |
21 | + | ||
22 | + | func randomize (bytes,range) = { | |
23 | + | let hash = sha256(bytes) | |
24 | + | let index = toInt(hash) | |
25 | + | (index % range) | |
8 | 26 | } | |
9 | 27 | ||
10 | - | true | |
28 | + | ||
29 | + | func incrementCounter (rare) = if ((rare == kCommon)) | |
30 | + | then IntegerEntry(kCommon, (countCommon + 1)) | |
31 | + | else if ((rare == kRare)) | |
32 | + | then IntegerEntry(kRare, (countCommon + 1)) | |
33 | + | else IntegerEntry(kLegendary, (countLegendary + 1)) | |
34 | + | ||
35 | + | ||
36 | + | func calculateRarity (transactionId) = { | |
37 | + | let tokenRare = randomize(transactionId, 100) | |
38 | + | if ((5 >= tokenRare)) | |
39 | + | then kLegendary | |
40 | + | else if ((tokenRare >= 80)) | |
41 | + | then kRare | |
42 | + | else kCommon | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | @Callable(i) | |
47 | + | func issueNft (name,desc,rarity,prefix) = if ((i.caller != this)) | |
48 | + | then throw("Only owner") | |
49 | + | else { | |
50 | + | let newToken = Issue(name, desc, 1, 0, false) | |
51 | + | let issueId = calculateAssetId(newToken) | |
52 | + | [newToken, StringEntry(((rarity + separator) + prefix), toBase58String(issueId))] | |
53 | + | } | |
54 | + | ||
55 | + | ||
56 | + | ||
57 | + | @Callable(i) | |
58 | + | func setPrice (price) = if ((i.caller != this)) | |
59 | + | then throw("Only owner") | |
60 | + | else [IntegerEntry(kPrice, price)] | |
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func pullTheLever () = { | |
66 | + | let amount = value(i.payments[0].amount) | |
67 | + | if ((i.payments[0].assetId != unit)) | |
68 | + | then throw("Pay in waves") | |
69 | + | else if ((correctPrice > amount)) | |
70 | + | then throw(("Payment amount < " + toString(correctPrice))) | |
71 | + | else { | |
72 | + | let rarity = calculateRarity(i.transactionId) | |
73 | + | let incrementStruct = incrementCounter(rarity) | |
74 | + | let tokenKey = ((rarity + separator) + toString(valueOrElse(getInteger(this, rarity), 0))) | |
75 | + | let assetKey = valueOrErrorMessage(getString(this, tokenKey), tokenKey) | |
76 | + | [incrementStruct, ScriptTransfer(i.caller, 1, fromBase58String(assetKey)), StringEntry((toString(i.caller) + tokenKey), assetKey)] | |
77 | + | } | |
78 | + | } | |
79 | + | ||
80 | + |
github/deemru/w8io/169f3d6 46.28 ms ◑