2022 Developer Survey is open! Take survey.

Questions tagged [randomness]

The tag has no usage guidance.

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

Pseudo Random generator based on real random seed

I have a big array of numbers and need to choose X of them randomly without repetition. I have a real random seed provided by an external oracle. Is there a known fair algorithm to create a pseudo ...
user avatar
  • 329
1 vote
2 answers
19 views

Is the key generated below valid and cryptographically secure?

For some reason, my React Native 0.68.0 app needs to generate private key for the Ethers wallet providing accessing to crypto.getRandomValues. The crypto.getRandomValues is polyfilled by react-native-...
user avatar
0 votes
1 answer
76 views

How Chainlink VRF fulfillRandomWords() callback function works?

I am using Chainlink VRF2 where I receive random numbers via a callback to this function: function fulfillRandomWords( uint256, /* requestId */ uint256[] memory randomWords ) internal ...
user avatar
  • 880
0 votes
0 answers
11 views

Questions on randomness on chain

Somebody asked three great question about on-chain randomness. I think they deserve a thread of their own. I'm listing them here again and those who are interested in discussions can either reply here ...
user avatar
  • 429
0 votes
0 answers
45 views

How to achieve verifiable randomness on Polygon, Avalanche, Arbitrum, etc...?

Chainlink VRF is only available on Ethereum and BSC so how does protocols on other chains achieve randomness?
user avatar
1 vote
1 answer
52 views

What is the max number of inputs that can be entered in a keccak256(abi.encodePacked()) function?

I'm learning to use the keccak function on cryptozombies, and seeing that this function takes three inputs: uint(keccak256(abi.encodePacked(now, msg.sender, randNonce))) made me wonder how many ...
user avatar
0 votes
2 answers
16 views

How does delaying on-chain randomness effect the security of number guessing games?

Say a number guessing game allows users to submit their guess before block N and reveals the winning number N + 100 games later, which is random number based on the block hashes of block N until block ...
user avatar
0 votes
1 answer
135 views

Why does getting random numbers using Chainlink take more than 30 seconds?

I'm writing an article and I'm using Chainlink VRF in one part. Theoretically, this is a two-transaction process, as it is impossible to storethe cryptographic proof on the blockchain and read the ...
user avatar
  • 141
0 votes
0 answers
101 views

Random number via Chainlink VRF call gas consumption

Trying to gen a random number via Chainlink VRF import "./VRFv2Consumer.sol"; ... VRFv2Consumer vrf = new VRFv2Consumer(12345); ... vrf.requestRandomWords(); uint256 randomWord = vrf....
user avatar
  • 101
0 votes
1 answer
14 views

False positives for Block State Dependency vulnerability

I've been analysing the contract in https://github.com/SoftSec-KAIST/Smartian/blob/main/examples/sol/BD_false.sol, which contains false positives for the bug Block State Dependency (see https://...
user avatar
  • 1
0 votes
1 answer
91 views

What is the return of uint(keccak256(_str));?

I'm doing the chapter 1 of the crypto zombies course. uint id = zombies.push(Zombie(_name, _dna)) - 1; NewZombie(id, _name, _dna); } function _generateRandomDna(string _str) ...
user avatar
  • 13
0 votes
1 answer
30 views

what is the chainlink VRF randomness details for xDai/Gnosis chain?

I looked into docs of chainlink but I couldn't find the VRF details for xDai/Gnosis chain network. Could you please help me find the following details? Chainlink VRF Coordinator address: LINK token ...
user avatar
  • 62
0 votes
1 answer
87 views

Randomizing values in mintable NFTs

I've read and written simple smart contracts in the past yet I'm relatively new to getting random data in a transaction, which seems to be harder than I've thought, due to the nature of determinism of ...
user avatar
0 votes
0 answers
202 views

Derived contract must override function "totalSupply". Two or more base classes define function with same name and parameter types

This is the code // SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/...
user avatar
  • 21
0 votes
1 answer
291 views

Want to generate non-repeative random number in a particular range

I need to generate a random number in range 1-5000 which are non duplicate. I had found solution to generate random number in particular range using chainlink and without chainlink also but i need to ...
user avatar
0 votes
0 answers
50 views

Fullfill randomness type error when Importing chainlink functions

Trying to inherit the randomness functions into my main contract(lottery). Getting a type error and I can't work out why. Tried all sorts. Is there a better way to inherit or import chainlink ...
user avatar
0 votes
1 answer
67 views

Commit reveal scheme with random number -- user chooses when to reveal... possible?

I've researched commit reveal schemes, but am not sure the following is possible... User mints a playing card. The number of card is hidden. At anytime, the user can choose to reveal the card number. (...
user avatar
  • 136
0 votes
1 answer
55 views

How do I get the PoW nonce of a specific block in solidity?

This question doesn't have an answer that shows how to get the PoW nonce for a specific block internally from within Solidity. From my understanding in Ethereum nonce is used for an account's tx ...
user avatar
  • 180
1 vote
1 answer
315 views

Chainlink: how to get an array of random numbers?

I'm using Chainlink VRF and its function to get an array of random numbers: function expand(uint256 randomValue, uint256 n) public pure returns (uint256[] memory expandedValues) { expandedValues = ...
user avatar
  • 141
0 votes
2 answers
197 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 ...
user avatar
0 votes
1 answer
109 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 = ...
user avatar
  • 503
1 vote
1 answer
286 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 ...
user avatar
0 votes
1 answer
87 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 ...
user avatar
0 votes
1 answer
28 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 ...
user avatar
4 votes
1 answer
370 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?
user avatar
1 vote
1 answer
598 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, ...
user avatar
0 votes
1 answer
101 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 ...
user avatar
1 vote
0 answers
52 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?
user avatar
0 votes
2 answers
707 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 ...
user avatar
  • 15
0 votes
2 answers
62 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 ...
user avatar
  • 188
1 vote
0 answers
119 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, ...
user avatar
  • 429
2 votes
1 answer
236 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 ...
user avatar
  • 43
1 vote
1 answer
967 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 ...
user avatar
0 votes
0 answers
198 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 ...
user avatar
1 vote
1 answer
30 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 ...
user avatar
1 vote
0 answers
136 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 ...
user avatar
  • 33
3 votes
1 answer
5k 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 ...
user avatar
  • 171
3 votes
3 answers
935 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 ...
user avatar
0 votes
1 answer
110 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 ...
user avatar
  • 868
9 votes
2 answers
4k 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 ...
user avatar
  • 868
1 vote
1 answer
255 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: ...
user avatar
0 votes
0 answers
323 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 ...
user avatar
  • 584
0 votes
1 answer
428 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 ...
user avatar
0 votes
1 answer
409 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 ...
user avatar
  • 9
2 votes
2 answers
525 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 ...
user avatar
0 votes
1 answer
246 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 ...
user avatar
  • 1,205
1 vote
1 answer
543 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: ...
user avatar
  • 1,205
2 votes
3 answers
913 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 ...
user avatar
  • 1,205
3 votes
0 answers
105 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 ...
user avatar
1 vote
1 answer
242 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 ...
user avatar
  • 25