tx · Vja8KeavLZvHAwp5ZcxanT4xx7P7Z9va937yhkmXNo5 3NCz3oCc3PNdauKDJEiPLzQwpBXXYEBc9p2: -0.00200000 Waves 2022.08.02 16:21 [2166919] smart account 3NCz3oCc3PNdauKDJEiPLzQwpBXXYEBc9p2 > SELF 0.00000000 Waves
{ "type": 13, "id": "Vja8KeavLZvHAwp5ZcxanT4xx7P7Z9va937yhkmXNo5", "fee": 200000, "feeAssetId": null, "timestamp": 1659446548577, "version": 2, "chainId": 84, "sender": "3NCz3oCc3PNdauKDJEiPLzQwpBXXYEBc9p2", "senderPublicKey": "3rvQsNbK5fc274oTJXxit5LUfVpNUHyPrKiaJZbmJ7zx", "proofs": [ "2rgY7rKx2eBoFmbT9LTqo9BXCjCSL49LptV4raNjRdLhaWBN79h7HGpUqDgL8Rp55iJSuSVT9Y3E8gvdQrQbniTQ" ], "script": "base64:BgIRCAISBgoECAgICBIDCgEIEgAOAAdrQ29tbW9uAgZjb21tb24ABWtSYXJlAgRyYXJlAAprTGVnZW5kYXJ5AglsZWdlbmRhcnkABmtQcmljZQIKcHJpY2VMZXZlcgAJc2VwYXJhdG9yAgF8AAdrQWN0aXZlAgZhY3RpdmUABmFjdGl2ZQkBEUBleHRyTmF0aXZlKDEwNTEpAgUEdGhpcwUHa0FjdGl2ZQAJY291bnRSYXJlCQBkAgABCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFBWtSYXJlAAAAC2NvdW50Q29tbW9uCQBkAgABCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFB2tDb21tb24AAAAOY291bnRMZWdlbmRhcnkJAGQCAAEJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUKa0xlZ2VuZGFyeQAAAQhpc0FjdGl2ZQADBQZhY3RpdmUFBHVuaXQJAAIBAg9TdG9yZSBpcyBhY3RpdmUBCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQ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QIMUGF5IGluIHdhdmVzBAxjb3JyZWN0UHJpY2UJARFAZXh0ck5hdGl2ZSgxMDUwKQIFBHRoaXMFBmtQcmljZQMJAGYCBQxjb3JyZWN0UHJpY2UFBmFtb3VudAkAAgECFlBheW1lbnQgYW1vdW50IDwgcHJpY2UEBnJhcml0eQkBEWNhbGN1bGF0aW9uUmFyaXR5AQgFAWkNdHJhbnNhY3Rpb25JZAQKc3RydWN0UmFyZQkBCmV4dHJhQ291bnQBBQZyYXJpdHkJAMwIAgUKc3RydWN0UmFyZQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIAAQkA2QQBCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzCQCsAgIJAKwCAgUGcmFyaXR5BQlzZXBhcmF0b3IJAKQDAQkBEUBleHRyTmF0aXZlKDEwNTApAgUEdGhpcwUGcmFyaXR5BQNuaWwAfNP9gQ==", "height": 2166919, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 676bakyFA99q3eahNLFUsBr24aKyg4e6C1PCtzGj86h2 Next: 4XQo9vUurvxsoaFXLMJE2bnnHDJCTf2J6Jago5N4M3wa Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let kCommon = "common" | |
5 | + | ||
6 | + | let kRare = "rare" | |
7 | + | ||
8 | + | let kLegendary = "legendary" | |
9 | + | ||
4 | 10 | let kPrice = "priceLever" | |
5 | 11 | ||
6 | 12 | let separator = "|" | |
7 | 13 | ||
8 | 14 | let kActive = "active" | |
15 | + | ||
16 | + | let active = getBooleanValue(this, kActive) | |
17 | + | ||
18 | + | let countRare = (1 + valueOrElse(getInteger(this, kRare), 0)) | |
19 | + | ||
20 | + | let countCommon = (1 + valueOrElse(getInteger(this, kCommon), 0)) | |
21 | + | ||
22 | + | let countLegendary = (1 + valueOrElse(getInteger(this, kLegendary), 0)) | |
23 | + | ||
24 | + | func isActive () = if (active) | |
25 | + | then unit | |
26 | + | else throw("Store is active") | |
27 | + | ||
9 | 28 | ||
10 | 29 | func randomize (bytes,range) = { | |
11 | 30 | let hash = sha256(bytes) | |
14 | 33 | } | |
15 | 34 | ||
16 | 35 | ||
36 | + | func extraCount (rare) = if ((rare == kCommon)) | |
37 | + | then IntegerEntry(kCommon, countCommon) | |
38 | + | else if ((rare == kRare)) | |
39 | + | then IntegerEntry(kRare, countCommon) | |
40 | + | else IntegerEntry(kLegendary, countLegendary) | |
41 | + | ||
42 | + | ||
17 | 43 | func calculationRarity (transactionId) = { | |
18 | 44 | let tokenRare = randomize(transactionId, 100) | |
19 | - | let numberToken = randomize(transactionId, 3) | |
20 | - | let common = "common" | |
21 | - | let rare = "rare" | |
22 | - | let legendary = "legendary" | |
23 | 45 | if ((5 >= tokenRare)) | |
24 | - | then | |
46 | + | then kLegendary | |
25 | 47 | else if ((tokenRare >= 80)) | |
26 | - | then | |
27 | - | else | |
48 | + | then kRare | |
49 | + | else kCommon | |
28 | 50 | } | |
29 | 51 | ||
30 | 52 | ||
34 | 56 | else { | |
35 | 57 | let newToken = Issue(name, desc, 1, 0, false) | |
36 | 58 | let issueId = calculateAssetId(newToken) | |
37 | - | [ | |
59 | + | [newToken, ScriptTransfer(i.caller, newToken.quantity, issueId)] | |
38 | 60 | } | |
39 | 61 | ||
40 | 62 | ||
47 | 69 | ||
48 | 70 | ||
49 | 71 | @Callable(i) | |
50 | - | func pullTheLever () = { | |
51 | - | let rarity = calculationRarity(i.transactionId) | |
52 | - | [ScriptTransfer(i.caller, 1, fromBase58String(getStringValue(this, rarity)))] | |
53 | - | } | |
72 | + | func pullTheLever () = if (!(active)) | |
73 | + | then throw("Not activated") | |
74 | + | else { | |
75 | + | let amount = value(i.payments[0].amount) | |
76 | + | if ((i.payments[0].assetId != unit)) | |
77 | + | then throw("Pay in waves") | |
78 | + | else { | |
79 | + | let correctPrice = getIntegerValue(this, kPrice) | |
80 | + | if ((correctPrice > amount)) | |
81 | + | then throw("Payment amount < price") | |
82 | + | else { | |
83 | + | let rarity = calculationRarity(i.transactionId) | |
84 | + | let structRare = extraCount(rarity) | |
85 | + | [structRare, ScriptTransfer(i.caller, 1, fromBase58String(getStringValue(this, ((rarity + separator) + toString(getIntegerValue(this, rarity))))))] | |
86 | + | } | |
87 | + | } | |
88 | + | } | |
54 | 89 | ||
55 | 90 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let kCommon = "common" | |
5 | + | ||
6 | + | let kRare = "rare" | |
7 | + | ||
8 | + | let kLegendary = "legendary" | |
9 | + | ||
4 | 10 | let kPrice = "priceLever" | |
5 | 11 | ||
6 | 12 | let separator = "|" | |
7 | 13 | ||
8 | 14 | let kActive = "active" | |
15 | + | ||
16 | + | let active = getBooleanValue(this, kActive) | |
17 | + | ||
18 | + | let countRare = (1 + valueOrElse(getInteger(this, kRare), 0)) | |
19 | + | ||
20 | + | let countCommon = (1 + valueOrElse(getInteger(this, kCommon), 0)) | |
21 | + | ||
22 | + | let countLegendary = (1 + valueOrElse(getInteger(this, kLegendary), 0)) | |
23 | + | ||
24 | + | func isActive () = if (active) | |
25 | + | then unit | |
26 | + | else throw("Store is active") | |
27 | + | ||
9 | 28 | ||
10 | 29 | func randomize (bytes,range) = { | |
11 | 30 | let hash = sha256(bytes) | |
12 | 31 | let index = toInt(hash) | |
13 | 32 | (index % range) | |
14 | 33 | } | |
15 | 34 | ||
16 | 35 | ||
36 | + | func extraCount (rare) = if ((rare == kCommon)) | |
37 | + | then IntegerEntry(kCommon, countCommon) | |
38 | + | else if ((rare == kRare)) | |
39 | + | then IntegerEntry(kRare, countCommon) | |
40 | + | else IntegerEntry(kLegendary, countLegendary) | |
41 | + | ||
42 | + | ||
17 | 43 | func calculationRarity (transactionId) = { | |
18 | 44 | let tokenRare = randomize(transactionId, 100) | |
19 | - | let numberToken = randomize(transactionId, 3) | |
20 | - | let common = "common" | |
21 | - | let rare = "rare" | |
22 | - | let legendary = "legendary" | |
23 | 45 | if ((5 >= tokenRare)) | |
24 | - | then | |
46 | + | then kLegendary | |
25 | 47 | else if ((tokenRare >= 80)) | |
26 | - | then | |
27 | - | else | |
48 | + | then kRare | |
49 | + | else kCommon | |
28 | 50 | } | |
29 | 51 | ||
30 | 52 | ||
31 | 53 | @Callable(i) | |
32 | 54 | func issueNft (name,desc,rarity,prefix) = if ((i.caller != this)) | |
33 | 55 | then throw("Only owner") | |
34 | 56 | else { | |
35 | 57 | let newToken = Issue(name, desc, 1, 0, false) | |
36 | 58 | let issueId = calculateAssetId(newToken) | |
37 | - | [ | |
59 | + | [newToken, ScriptTransfer(i.caller, newToken.quantity, issueId)] | |
38 | 60 | } | |
39 | 61 | ||
40 | 62 | ||
41 | 63 | ||
42 | 64 | @Callable(i) | |
43 | 65 | func setPrice (price) = if ((i.caller != this)) | |
44 | 66 | then throw("Only owner") | |
45 | 67 | else [StringEntry(kPrice, price)] | |
46 | 68 | ||
47 | 69 | ||
48 | 70 | ||
49 | 71 | @Callable(i) | |
50 | - | func pullTheLever () = { | |
51 | - | let rarity = calculationRarity(i.transactionId) | |
52 | - | [ScriptTransfer(i.caller, 1, fromBase58String(getStringValue(this, rarity)))] | |
53 | - | } | |
72 | + | func pullTheLever () = if (!(active)) | |
73 | + | then throw("Not activated") | |
74 | + | else { | |
75 | + | let amount = value(i.payments[0].amount) | |
76 | + | if ((i.payments[0].assetId != unit)) | |
77 | + | then throw("Pay in waves") | |
78 | + | else { | |
79 | + | let correctPrice = getIntegerValue(this, kPrice) | |
80 | + | if ((correctPrice > amount)) | |
81 | + | then throw("Payment amount < price") | |
82 | + | else { | |
83 | + | let rarity = calculationRarity(i.transactionId) | |
84 | + | let structRare = extraCount(rarity) | |
85 | + | [structRare, ScriptTransfer(i.caller, 1, fromBase58String(getStringValue(this, ((rarity + separator) + toString(getIntegerValue(this, rarity))))))] | |
86 | + | } | |
87 | + | } | |
88 | + | } | |
54 | 89 | ||
55 | 90 |
github/deemru/w8io/026f985 35.46 ms ◑