tx · 2g1LSyZQYnkTk1SpMxLGcv9GwGBdPFMShqphRtf9KVzi
3Mwb8GE6NHaDxJTby35u2sNAEmDQMWYupCn: -0.01000000 Waves
2023.06.11 17:53 [2618153] smart account 3Mwb8GE6NHaDxJTby35u2sNAEmDQMWYupCn > SELF 0.00000000 Waves
{
"type": 13,
"id": "2g1LSyZQYnkTk1SpMxLGcv9GwGBdPFMShqphRtf9KVzi",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1686495215471,
"version": 2,
"chainId": 84,
"sender": "3Mwb8GE6NHaDxJTby35u2sNAEmDQMWYupCn",
"senderPublicKey": "6oJuynzr7rKRYRDWhDrENciDLidQuVGfe82pK7hr5nev",
"proofs": [
"57rBq2Grn9LQR8RNB2qShYRfyV1skzJEipweYG3J5Ggqwb2FULTk5RSUNJXm8rJo11WRwz7Z2q5pCamAfP9vvcsv"
],
"script": "base64:BgIJCAISABIDCgEBBAALcmFuZG9tRGVsYXkAAgEJa2V5Q29tbWl0AQdhZGRyZXNzCQCsAgICE2ZpbmlzaEJsb2NrRm9yQWRkcl8FB2FkZHJlc3MBD2dldFJhbmRvbU51bWJlcgIIbWF4VmFsdWUMZmluaXNoSGVpZ2h0BA9yYW5kb21TZWVkQmxvY2sJAQV2YWx1ZQEJAO0HAQUMZmluaXNoSGVpZ2h0BApyYW5kb21IYXNoCQD3AwEJAQV2YWx1ZQEIBQ9yYW5kb21TZWVkQmxvY2sDdnJmCQBqAgkAsgkCBQpyYW5kb21IYXNoABAFCG1heFZhbHVlAQZwc2V1ZG8BAW4ECnJhbmRvbUhhc2gJAPcDAQkAywECCQEFdmFsdWUBCAkBBXZhbHVlAQkA7QcBBQZoZWlnaHQDdnJmCQCaAwEFAW4EB2hhc2hJbnQJALIJAgUKcmFuZG9tSGFzaAAYCQCUCgIFB2hhc2hJbnQJAGoCBQdoYXNoSW50ACUCAWkBBmNvbW1pdAAEC2ZpbmlzaEJsb2NrCQBkAgUGaGVpZ2h0BQtyYW5kb21EZWxheQkAlAoCCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEJa2V5Q29tbWl0AQkApQgBCAUBaQZjYWxsZXIFC2ZpbmlzaEJsb2NrBQNuaWwFC2ZpbmlzaEJsb2NrAWkBBnJldmVhbAEIbWF4VmFsdWUEB2NvbW1LZXkJAQlrZXlDb21taXQBCQClCAEIBQFpBmNhbGxlcgQLZmluaXNoQmxvY2sJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnwgBBQdjb21tS2V5AhtZb3UgaGF2ZSB0byBjb21taXQoKSBmaXJzdCEDCQBmAgULZmluaXNoQmxvY2sFBmhlaWdodAkAAgECHlJhbmRvbSBudW1iZXIgaXMgbm90IHJlYWR5IHlldAQEcmFuZAkBD2dldFJhbmRvbU51bWJlcgIFCG1heFZhbHVlBQtmaW5pc2hCbG9jawkAlAoCCQDMCAIJAQtEZWxldGVFbnRyeQEFB2NvbW1LZXkFA25pbAUEcmFuZADkVdtd",
"height": 2618153,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: A233XTEiF5FEpvnXHgj9LjwR8h9u37eTKp2qNQGJhmAW
Next: 6V8Pd3AwFcYnxwALZywD5QnoQuu6QLJPDemrrq45ixRX
Diff:
Old | New | | Differences |
---|
15 | 15 | | |
---|
16 | 16 | | func pseudo (n) = { |
---|
17 | 17 | | let randomHash = sha256((value(value(blockInfoByHeight(height)).vrf) + toBytes(n))) |
---|
18 | | - | (toInt(randomHash, 25) % 37) |
---|
| 18 | + | let hashInt = toInt(randomHash, 24) |
---|
| 19 | + | $Tuple2(hashInt, (hashInt % 37)) |
---|
19 | 20 | | } |
---|
20 | 21 | | |
---|
21 | 22 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 6 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let randomDelay = 2 |
---|
5 | 5 | | |
---|
6 | 6 | | func keyCommit (address) = ("finishBlockForAddr_" + address) |
---|
7 | 7 | | |
---|
8 | 8 | | |
---|
9 | 9 | | func getRandomNumber (maxValue,finishHeight) = { |
---|
10 | 10 | | let randomSeedBlock = value(blockInfoByHeight(finishHeight)) |
---|
11 | 11 | | let randomHash = sha256(value(randomSeedBlock.vrf)) |
---|
12 | 12 | | (toInt(randomHash, 16) % maxValue) |
---|
13 | 13 | | } |
---|
14 | 14 | | |
---|
15 | 15 | | |
---|
16 | 16 | | func pseudo (n) = { |
---|
17 | 17 | | let randomHash = sha256((value(value(blockInfoByHeight(height)).vrf) + toBytes(n))) |
---|
18 | | - | (toInt(randomHash, 25) % 37) |
---|
| 18 | + | let hashInt = toInt(randomHash, 24) |
---|
| 19 | + | $Tuple2(hashInt, (hashInt % 37)) |
---|
19 | 20 | | } |
---|
20 | 21 | | |
---|
21 | 22 | | |
---|
22 | 23 | | @Callable(i) |
---|
23 | 24 | | func commit () = { |
---|
24 | 25 | | let finishBlock = (height + randomDelay) |
---|
25 | 26 | | $Tuple2([IntegerEntry(keyCommit(toString(i.caller)), finishBlock)], finishBlock) |
---|
26 | 27 | | } |
---|
27 | 28 | | |
---|
28 | 29 | | |
---|
29 | 30 | | |
---|
30 | 31 | | @Callable(i) |
---|
31 | 32 | | func reveal (maxValue) = { |
---|
32 | 33 | | let commKey = keyCommit(toString(i.caller)) |
---|
33 | 34 | | let finishBlock = valueOrErrorMessage(getInteger(commKey), "You have to commit() first!") |
---|
34 | 35 | | if ((finishBlock > height)) |
---|
35 | 36 | | then throw("Random number is not ready yet") |
---|
36 | 37 | | else { |
---|
37 | 38 | | let rand = getRandomNumber(maxValue, finishBlock) |
---|
38 | 39 | | $Tuple2([DeleteEntry(commKey)], rand) |
---|
39 | 40 | | } |
---|
40 | 41 | | } |
---|
41 | 42 | | |
---|
42 | 43 | | |
---|