Questions tagged [randomness]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

On-chain Random Number Generator

I've been doing some research on gasleft() (used to be msg.gas but is now deprecated) and was unable to find any specifics on how or where this value is defined. I was able to find another detailed ...
0
votes
1answer
63 views

Is it possible to use one verifiably random uint to uniformly generate a randomised distribution?

Assume I have a selection of token IDs, for instance: uint256[] public tokenIds = [1,2,3,4,5]; Now, incorporate a random number generated by Chainlink, let's say: uint256 public randomNumber = ...
1
vote
1answer
60 views

NFT minting in random way from csv file

I am a new in solidity so have a questions regarding minting NFT from csv. There is a .csv file with 1000 rows in each row - 5 attributes. These rows should be taken randomly for lazy minting 1000 NFT ...
0
votes
1answer
50 views

Send Token to Random Addresses

First of all, is this the right way to send a token to a random address? _mint(address(keccak256(abi.encodePacked(now))), _amount) If so, how do I make it to repeat itself 10 times (sending a token to ...
0
votes
1answer
20 views

Utilizing random data provided by Math.random

I was interested in developing a generative project that would consist of lines of randomly generated text. Unlike projects that have already done something similar, this project takes it a bit ...
4
votes
1answer
272 views

What is the purpose of using a true random number for an NFT?

I don't understand what the purpose of using Chainlink VRF for my NFT's generation is. Why don't I just launch and pick the NFT traits myself?
1
vote
1answer
185 views

Get random number without replacement in Solidity

I am trying to sample a random number without replacement until the pool of possible numbers runs out, using Solidity. In pseudo-code, it should be something like this: 1. Initial pool of numbers: (1, ...
0
votes
1answer
46 views

Trying to generate random numbers in a dice game in solidity with chainlink?

I am trying to learn solidity by doing a dice game, I found code online that I would like to start with however I am stuck with trying to get the definition of _vrfConsumerBase and _link. I am aware ...
1
vote
0answers
26 views

Possibilities in Solidity

I want to create an NFT crowd sale contract. I have 4 egg. People will buy them with possibilities, I mean for exp: 1st egg's chance is 1%, 2nd is 5% and so on. What is the best way of doing this?
0
votes
2answers
326 views

Is it possible to generate unique, non-duplicate, random numbers in solidity?

For reference, this question is basically the same as this one, but for solidity. Of course that in theory you can generate a random, unique, non-duplicate number using solidity. The problem is most ...
0
votes
2answers
41 views

Biased Random Number based upon balance of ERC20 tokens

I have been able to use Random Number Generator from Chainlink. But I need something that has biased Random Number. What I mean is suppose a userA has 100 ERC20 Tokens balance but another userB has ...
1
vote
0answers
27 views

Run time smart contract random number generator

I am wondering what problems the following function could have in generating a random number in runtime. I understand miners can manipulate transactions if environmental variables such as block.hash, ...
2
votes
1answer
84 views

ChainLink VRF number length

Is the length (number of digits) of the number generated by ChainLink VRF always the same? My contract executes modulus operations to get subnumbers of the big number generated, so if it's not the ...
1
vote
1answer
444 views

Chainlink VRF fulfillRandomness doesn't use enough gas to perform function - how to get it to use more?

Chainlink VRF allows users to get a random number by calling requestRandomness and then waiting for the fulfillRandomness callback to be called by the Chainlink contract. I have a function ...
0
votes
0answers
80 views

"Gas estimation failed" error when sending eth to Chainlink VRF function?

I have a simple request and fulfill randomness using chainlink VRF, and it works fine when calling with 0 ether, but if I send a non-zero amount I get a 'gas estimation failed' error. To be clear, I ...
1
vote
0answers
18 views

ETH 2 random election attack vectors?

Since proof-of-stake algorithms (like ETH 2) use random sampling to choose the next validator to propose the next block, are there attack vectors with this random selection? It seems to use RANDAO, a ...
1
vote
0answers
119 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 ...
3
votes
1answer
4k 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
498 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
54 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 ...
5
votes
1answer
2k 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
145 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
245 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
222 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
1answer
239 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
1answer
184 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
135 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
318 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
542 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 ...
3
votes
0answers
65 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
171 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
387 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
36 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
68 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 ((...
5
votes
1answer
276 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
82 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
677 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
623 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
78 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
32 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
2k 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 ...
2
votes
0answers
368 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
786 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
73 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
33 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
24 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
120 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
111 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
131 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 ...