Questions tagged [randomness]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
14 views

“Good enough” random number in BSC

I'm trying to develop a weighted probability selection algorithm on BSC and I think I need an algorithm that can generate a random number within a given range for that. What would be a "good ...
1
vote
0answers
32 views

What is best approach for generating random NFTs?

I am thinking of developing small DApp where user would collect cards (NFT). Each card would have some image and value associated with it. User collects cards by purchasing Pack of Five Cards which ...
3
votes
3answers
150 views

Can we use block hash as verifiable randomness for the off-chain lottery?

My team is writing a discord lottery bot, we want to use the block hash of some block in the future as a seed for the random generator. We want to allow lottery participants to independently verify ...
0
votes
1answer
21 views

Is Oraclize / Provable Things dying? [closed]

I'm doing some research on how to generate truly random numbers on the blockchain. Aside from Chainlink VRF, the other viable solution seems to be Provable Things (former Oraclize) with their random ...
3
votes
1answer
65 views

What are the costs of using Chainlink to generate a random number using VRF?

I'm doing some research about generating true randomness on the Ethereum blockchain. Of course I came across Chainlink and its VRF solution. Although there are many tutorials around, some from ...
1
vote
1answer
65 views

How to pay an Oracle with Link token if I have payable with Ethereum values?

First of all, I'm new to this smart contract world, and so I would like to apology if it's a stupid question. I'm programming with Remix and with Solidity as programming language.I have 2 files: ...
0
votes
0answers
74 views

Alternatives to get LINK tokens in Ropsten, for RNG

Sorry if this question sounds like very newbie (and maybe it is. I'm developing a Smart Contract which needs a random number generation, and after researching some time it seems that ChainLink VRF ...
0
votes
1answer
33 views

How can you cheaply choose from a dynamic array randomly, with an oracle generated seed number, in Solidity?

In JS you could use this and call it a day. let randomArrayEntry = myArray[Math.floor(Math.random() * myArray.length)]; However, in Solidity everything is deterministic unless you call an outside ...
0
votes
0answers
13 views

Creating several objects in the same transaction (data repetition)

I'm working with genetic algorithms and I need to create a population. Currently I have this function: /// @notice Create a new individual function createIndiv(uint _popSize) public{ for(uint i = ...
0
votes
1answer
113 views

Minereum Lucky Draw claims 100% Safe randomness on a smart contract without oracles, is it really possible? [duplicate]

Is the way Minereum Lucky Draw game works really safe 100% onchain RNG and verifiable on smart contract? They claim yes but I would like to know expert technical answer for this, if so, isn't this a ...
0
votes
0answers
43 views

How to select the next author of block in Proof-of-Stake? [duplicate]

There is a common (but not precise) opinion that the block's author selection is random in Proof-of-Stake. I therefore posted a question here: Proof-of-Stake: How to prevent someone from being always ...
0
votes
1answer
49 views

Can someone read this private variable?

my purpose is to generate a random key when the smart contract is created and save that key in a private variable. I don't what to know its value either. Let's take for example the code below: pragma ...
0
votes
1answer
47 views

Blockhash Minus-256 Problem [duplicate]

What is meant by Blockhash Minus-256 Problem? I am reading an article at: Bad Randomness It talks about Blockhash Minus-256 problem but does not explain much about it. As a result I can’t ...
0
votes
1answer
108 views

Blockhash: Register the block number

I am reading the following article from a website: bad randomness In the context of Blockhash the author says: For instance, a good protocol (formulating a random trial as a “bet”) is the following: ...
2
votes
3answers
174 views

What is meant by on-chain randomness? What is the difference between on-chain and off-chain operations in the context of randomness?

I want to understand on-chain and off-chain operations in the context of randomness. Kindly provide me an example so that its clear to me. I got one post here: What are offchain and onchain ...
2
votes
0answers
39 views

Advantage of Chainlink's VRF over commitment scheme chain

News Chainlink announced a randomness oracle via VRF: https://blog.chain.link/verifiable-random-functions-vrf-random-number-generation-rng-feature/. Question What is the advantage of an VRF over a ...
1
vote
1answer
79 views

How can I convert an element of a byte32 array to number?

The array contains an SHA256 hash. I want to add up 2 hexadecimal values, and later multiply them by 1.125 (only keeping integer). The resulted number would represent an alphanumerical character, it ...
0
votes
2answers
186 views

How to generate a unique random number in web3.js?

I need to generate a unique 128 bit number and know this number in my web3.js script. Previously I tried this (create these numbers in my contract and retrieve them to web3.js). It seems impossible. ...
0
votes
1answer
28 views

For what reasons is it insecure to use block hashes from past blocks for randomness?

I understand that using the current block hash gives the miner the ability to possibly discard the block, but my question is about using a block hash from a past block. For example, I could look 128 ...
0
votes
0answers
55 views

Bad randomness exploitation

There is a contract with a betting function that calculates a random number and send you back a reward if winning. The betting function looks like: function bet() public payable { if ((...
3
votes
1answer
128 views

How does eth2 Random Election Work?

In eth2 validators will be randomly selected. What is the formula for how this random selection works?
0
votes
2answers
67 views

generation random number

uint private seed; // starts from 0 (including) to _length number (excluding) function random(uint _length) private returns(uint) { seed = seed.add(block.timestamp.add(uint(msg.sender))); ...
1
vote
3answers
268 views

Solidity - Generate multiple, unpredictable random numbers that do not depend on input

I know that the "how to generate random number" in solidity is a very common question. However, after reading the great majority of answers I did not find one to fit my case. A short description of ...
1
vote
1answer
152 views

Weighted Random Number Array generation in solidity

I have an array like this in the array, uint256[] public numberArr= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; Each number in an array have their own weight, uint256[] public weightNumberArr = [1, 3, 9, 7, 15,...
1
vote
0answers
59 views

How to fix gas estimation failed error while getting random number from Provable Random DS?

I'm using Provable for getting a random number and I am using following code snippet from their github: https://github.com/provable-things/ethereum-examples/blob/master/solidity/random-datasource/...
0
votes
0answers
34 views

How can I use bitcoin block stamp as seed for random number generation?

I am trying to create an ethereum based smart contract that shall generate random number. After searching around, I get to know that ethereum block stamp is vulnerable to miners hacks and false ...
2
votes
0answers
29 views

Increasing the difficulty/cost of manipulating an on-chain PRNG?

well, from what I understand since everything on-chain is deterministic so theoretically there's no way of having a real cryptograhically secure random number generator that cannot be manipulated by ...
0
votes
1answer
957 views

TypeError: Wrong argument count for function call: 2 arguments given but expected 1. Use abi.encodePacked

I was playing with this post code example: function random() private view returns (uint8) { return uint8(uint256(keccak256(block.timestamp, block.difficulty))%251); } But I'm always ...
1
vote
0answers
182 views

exploiting keccak for random number generation?

Whenever a ticket will be purchased, a random number will be generated function _mightWin() internal { address _player = msg.sender; // players address uint256 ...
4
votes
1answer
463 views

String of random characters [duplicate]

I understood that solidity can only generate pseudo-random numbers. Although, is there any way of generating a, let's say 10 character, random string?
2
votes
1answer
60 views

Known cases of miners withholding blocks when used as randomness?

There are some applications that use the blockhash as a source of randomness, often with a payout similar to a lottery. I've heard of attacks where it would be more profitable for a miner to withhold ...
0
votes
1answer
30 views

How does this 4-line labyrinth contract work?

contract Labyrinth { uint entropy; function getRandomNumber() public returns (uint) { entropy ^= uint(blockhash(entropy % block.number)); return entropy; } } I found this weird gist ...
0
votes
1answer
20 views

changing source of random number based on reward?

Would this be an acceptable way to produce a random number dependent on the reward? Say if the reward is high enough to entice a miner to manipulate the block then the contract will utilize oraclize. ...
0
votes
1answer
95 views

Safe for random number?

My thought is that we come up with a random number in one block and make it private so no one can see it. The timer will allow a few blocks to be mined and then the revealNumber function allows the ...
2
votes
1answer
99 views

Rolling a die at some point in the future

This question has been asked previously by someone else but the answers weren't quite sufficient. I want to write a simple contract that will yield an immutable 'random' number after a period of time....
0
votes
0answers
51 views

Is this a good way to get a random number on solidity? [duplicate]

I need to generate a random number for betting games. Is this pattern safety solution? mapping(uint => address) playerMapping; address[] players; // here is contract will save block.number of ...
2
votes
2answers
122 views

How to limit N bytes to value range using Oraclize Ledger-Proof Random Number — unfair raffle

Lets say you have 50 tickets to a raffle. You choose to return 4 random bytes from the ledger proof RNG(https://github.com/oraclize/ethereum-examples/blob/master/solidity/random-datasource/...
4
votes
1answer
254 views

What is the algorithm to select random validators in PoS? [duplicate]

As I know, Ethereum Casper PoS implementation randomly selects 250 validators from the validator poll for an epoch. What is the random algorithm for this selection?
4
votes
2answers
3k views

i want get random number between 100-999, as follows

function random() internal returns (uint) { uint random = uint(keccak256(now, msg.sender, nonce)) % 1000; nonce++; return random; } In this way, you can generate random numbers, but there ...
2
votes
1answer
172 views

Using oraclize and solidity-util - having trouble splitting string separated by space

I am learning to use Oraclize to connect it to random.org to generate random numbers. Here's my test contract code: pragma solidity ^0.4.25; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"...
2
votes
1answer
39 views

Random number between 0 and 1 - quick little question

I know that the topic of random number has been discussed tremendous amount of times already but I have one small question. I need to get a pseudo random number (not ungamealbe), as simply as ...
0
votes
1answer
144 views

Why is this random algorithm not good enough?

Many lotteries on Ethereum use random algorithms to determine a 'winner'. For instance, this function is bad because has some vulnerabilities (read here about some): function random() private view ...
2
votes
2answers
606 views

Need of a random number oracle

I am looking for the less gas consuming random number generator. I think i need an oracle but can you direct me to the best ? Thanks
4
votes
2answers
49 views

Block archived event inside blockchain

I want to write a gambling smart contract, that will be based on time (on block number in the ethereum blockchain). What is the best way to do some work when current network block will archive some ...
1
vote
0answers
38 views

How can I securely generate a random number in my smart contract at POA?

I heard that a block of random function results can be dropped by a malicious miner. Can POA prevent this? How can I securely generate a random number in my smart contract?
2
votes
0answers
186 views

How bad are future blockhashes as source of entropy exactly?

This is not a duplicate (see below) Before you answer “bad, the miner can influence them”, please let me specify the question. It’s clear that things like timestamp should not flow into a random ...
3
votes
1answer
1k views

Any Pseudo Random Number Generator that can generate different numbers in the same block?

All the Pseudo Random Number Generators that depend on block hash or block time seems to generate the same "random" number for the same block. Is there any way to generate different numbers in the ...
1
vote
0answers
81 views

are all bits of a keccak256 'uniformly distributed'? [closed]

If I have a truly random data source, and generate keccak256 hashes of the numbers of this source: N1 = keccak256(rnd1) N2 = keccak256(rnd2) N3 = keccak256(rnd3) ... are all 256 bits of the ...
1
vote
0answers
45 views

PoA (like rinkeby) safer to generate random number (RNG) this function than POW/POS?

How can I securely generate a random number in my smart contract? I heard that a block of random function results can be dropped by a malicious miner. Can POA prevent this?
1
vote
0answers
36 views

How do mrand.Float64() output the same result with same order in reorganisation?

Recently, I did go deep into the code of reorganisation in blockchain, but I'm confused by the mrand.Float64() in WriteBlockWithState. Here is the code: original code position // If the total ...