Questions tagged [randomness]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
26 views

What are the best up-to-date secure approaches of generating pseudorandom number in Solidity? [duplicate]

I am thinking about creating a lottery with more than one winner and one round for users. Please don't consider usual 'commit-reveal' scheme. However, person can claim rewards on their own at the end ...
Victor's user avatar
  • 13
0 votes
0 answers
23 views

Create a random number (that no one knows) at time A and reveal it when event B occurs

Similar things have been discussed before, but the requirement is - no one (no one non neutral that is) should have access to the secret before the reveal, so commit-and-reveal scheme doesn't work. If ...
Phosphorescent's user avatar
1 vote
0 answers
42 views

Is there any natural source of entropy when running `forge test`?

I'm looking for a pseudo-random value that is different each time the command is run. Either forge test or forge script.
Paul Razvan Berg's user avatar
1 vote
1 answer
48 views

Unable to fetch a random number from chainlink VRF. Can someone help

array of randomWords is set 0 in the function requestRandomWords() s_requests[requestId] = RequestStatus({ randomWords: new uint256[](0), exists: true, fulfilled: ...
Daneshwari Pattanashetti's user avatar
2 votes
1 answer
91 views

How do I make a contract mint NFTs randomly with a metadata that's already on IPFS?

I want to deploy an NFT that at mint time, selects at random one of an enum of several metadata choices. Obviously I can't do this on a static mint site because you could exploit the contract by ...
ChristianOConnor's user avatar
2 votes
0 answers
106 views

Is there an alternative to Chainlink to get a random number in a solidity contract?

I'm trying to create an NFT that selects at random between 3 json metadata files. The only way I know of to do this is to use Chainlink. I've seen one tutorial that implements "@chainlink/...
ChristianOConnor's user avatar
1 vote
2 answers
78 views

Is ChainLink's VRF susceptible to a 51% attack?

I do not know all of the details of how ChainLink's nodes and oracles work (hence why I am on here) but I did a little research on my own. According to a Gemini blog post by Cryptopedia, chainlink ...
chriscrutt's user avatar
0 votes
1 answer
43 views

How is the seed for choosing proposers calculated if RANDAO fails to produce new randomness?

I understand that RANDAO can fail to produce new randomness if one of the participants doesn't submit their secret. What are the exact mechanics of such situation? Some more details that would be ...
Aleksander Misztal's user avatar
2 votes
1 answer
3k views

"selfdestruct" deprecated in Solidity 0.8.18

I have noticed that although the new compiler 0.8.18 has nice new feature in form of a block.prevrandao , it also has a deprecated selfdestruct feature. Is there an alternative to that or is it gone ...
f22daniel's user avatar
  • 193
0 votes
1 answer
95 views

How to generate secure and pure Randomness number without Chainlink VRF?

I found that the Chainlink VRF do not really support all the networks. So, I am considering to use off-chain and make my oracle to generate random number. I have a vague idea just down below Create a ...
DHC's user avatar
  • 199
1 vote
2 answers
135 views

ERC721 Minting Randomness

Trying to figure out how to do the following. I wouldn't need the code, just an understanding of viable methods as I can't locate an answer. An NFT minting process for 2,000 NFTs. IDs from 0-9 would ...
ApplowPi's user avatar
  • 111
0 votes
0 answers
47 views

using block.coinbase as a random number

Can I use block.coinbase as a seed to generate random numbers in smart contract? Can it be guessed except for the validator?
shafiul nobe's user avatar
0 votes
1 answer
186 views

VRFV2WrapperConsumerBase function requestRandomness with error undeclared identifier

Working on migrating VRF to V2 but met with error that requestRandomness function is undeclared identifier. Previous V1 the VRF was implemented using 'VRFConsumerBase.sol'. Currently using V2 '...
0x Senzel's user avatar
0 votes
1 answer
28 views

Are there any downsides to revealing all the participants of a lottery, to the public?

In my smart contract which is lottery I generate a random number. Then I pick a user based on his sequential place in the list of all the participants. This sequential place gets assigned to every ...
Kum's user avatar
  • 75
0 votes
0 answers
70 views

I can call 34 random words from Chainlink VRF but not 35 or more. Why?

I am trying to call my requestRandomness function in my main contract that calls a VRFCoordinatorV2Mock contract in my local hardhat environment. According to my unit tests I am able to emit a ...
Mitchs's user avatar
  • 11
1 vote
1 answer
258 views

Accessing RANDAO value from a smart contract

is there a way to access the block randomness from within a smart contract or does the value reside only on the consensus layer?
Jan Beneš's user avatar
0 votes
1 answer
29 views

Execute an ethereum transaction every X amount of blocks within a smart contract?

I would like to build a smart contract where users deposit crypto into a lottery like system. Every 10 blocks that have passed on the underlying chain I want to generate a random number and send out a ...
Denis Ivanov's user avatar
0 votes
0 answers
28 views

How to improve a lottery smart contract to make it more transaprent and frank?

There's a lottery smart contract. Let's say it's a private blockchain, therefore the source code can't be viewed. The calls to a smart conract can be viewed on blockchain explorer, though. It's only ...
Kum's user avatar
  • 75
1 vote
1 answer
116 views

What happens if by randomness you deploy a contract to the same address then an existing EOA

What happens if by randomness you deploy a contract to the same address then an existing EOA? Would the deployment be rejected? Would it only be rejected if the EOA has no transaction history i.e a ...
FreddyC's user avatar
  • 161
2 votes
1 answer
128 views

Random function

Is this function safe? I want to generate a random number without any external input. abstract contract F { //current block time when the contract was created uint256 private currentTime=block....
Vlad Cristian Stanica's user avatar
6 votes
1 answer
952 views

Using block.prevrandao as randomness for Miller-Rabin Primality test

I am interested in using the new PREVRANDAO value as a source of pseudo-randomness in calculating the Miller-Rabin probabilistic primality test on-chain. Chainlink VRF is an option but ideally I would ...
riordant's user avatar
2 votes
2 answers
366 views

Randomness in Proof of Stake

The new Proof of Stake chain modifies the old DIFFICULTY opcode to be PREVRANDAO and changes its semantics (https://eips.ethereum.org/EIPS/eip-4399). How does the new opcode compare to the old opcode ...
Lauri Peltonen's user avatar
0 votes
1 answer
66 views

Participating in RANDAO

Can people participate in RANDAO and earn some extra bucks along the way? According to RANDAO github, it seems possible: The RNG cycle is very short, and could be for example 20 cycles in one hour, ...
Hitit's user avatar
  • 101
2 votes
3 answers
380 views

How to generate random number and get it at the same time using Chainlink VRFv2?

I need to generate random number, on a single function hit and get it there only. I am not able to do that, due to block confirmations required which is set to min. 3. Is there any way to get this or ...
Manav Notnani's user avatar
1 vote
1 answer
12 views

Link tokens required on Avg for random number generation

Can someone tell how much link tokens are required on an avg. to generate random number via VRF chainlink method??
Manav Notnani's user avatar
1 vote
1 answer
85 views

Guess the number game , not working

I am trying to write a game on smart contract which is a game in which the player has to type in 5 guesses, and based on how close they were to the actual number, they would receive ether as prize. ...
Rjey's user avatar
  • 17
2 votes
2 answers
115 views

How to keep track of already minted NFTs while minting ERC721 NFTs Randomly?

I am working on random minting of ERC721 Tokens... I am using Chainlink VRF For randomisation. The confusion I have is that how can I keep track of NFTs that have been already minted... Because VRF ...
Abdullah Hanif Chaudhary's user avatar
1 vote
2 answers
293 views

Get first digit of number [closed]

In Solidity, how do you get the first digit of a two-digit number, like 65 for example?
dNyrM's user avatar
  • 675
2 votes
1 answer
173 views

Can I generate multiple random uint8 from a uint256?

The chainlink VRF returns a uint256, for my application I need a uint8. If I utilize one uint256 and break it up into separate uint8 is that still secure as a source of randomness? Also, what's the ...
Danny B's user avatar
  • 313
0 votes
1 answer
188 views

Is using modulo to get a range from Chainlink's VRF number a good idea?

I'm building a lottery game contract and I need to get a range of values from chainlink VRF's number. The range is the length of the players list. For simplicity, I've made a simple contract that ...
AncientVeil's user avatar
2 votes
1 answer
381 views

Efficiently fill a Solidity array with a range of numbers

does anyone know how I can fill an array with numbers 1 - 10,000 efficiently? For example, in our constructor we have the following but it doesn't work due to gas costs; too many items to push to a ...
binkie's user avatar
  • 121
0 votes
1 answer
356 views

What's the recommended way to allow users to mint random ERC-721 tokens, reveal metadata, and offer full transparency in 2022?

I'm writing an ERC-721 contract to launch a collection of paintings and I'm considering a few semi-generative variations to make the total supply about 1,000 tokens with multiple rarities. I'd like to ...
Mentakatz's user avatar
  • 101
1 vote
1 answer
239 views

random number from chainlink vrf at hardhat test always 0

I tried to test chainlink vrf at hardhat test with vrfcoordinatormock. test is work fine but random words and request id are always 0. is It correct that returning 0 from MockVRF? const ...
Dean97K's user avatar
  • 23
0 votes
1 answer
26 views

Can this simple RNG be hacked?

For a game I have implemented Chainlink VRF and a basic RNG for small games where the fee of Chainlink wouldn't make sense. For the 3rd parameter to abi.encodePacked (some seed data? docs suck so not ...
Dominic's user avatar
  • 117
0 votes
3 answers
358 views

Revert if caller of contract is another contract [duplicate]

I'm trying to limit the access of functions in my contract to only normal user addresses, to prevent the 'revert-and-retry attack' described here. Quick excerpt from that link: victim.tryMyLuck(); ...
Enzo's user avatar
  • 40
1 vote
0 answers
135 views

Random number generator

I am trying to hack a random number generator contract as follows : // SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract Guess { uint256 private randNonce; uint256 private result;...
Ashish kumar's user avatar
0 votes
1 answer
176 views

Whenever i write some code in Chianlink VRF fulfillRandomWords function it does not get updated

I have already set my Subscriptions for Chainlink Added consumer and subscription have sufficient Link as well No Error occurs whenever I call the requestRandomWords function The chainlink ...
Sulaman Khan's user avatar
0 votes
1 answer
63 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 ...
Stormsson's user avatar
  • 369
1 vote
2 answers
65 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-...
user938363's user avatar
3 votes
1 answer
810 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 ...
Emrah's user avatar
  • 1,524
0 votes
1 answer
215 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?
Niccolò Fant's user avatar
1 vote
1 answer
258 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 an online Solidity tutorial, and seeing that this function takes three inputs: uint(keccak256(abi.encodePacked(now, msg.sender, randNonce))) made me wonder ...
Lyu Hiroyama's user avatar
0 votes
2 answers
20 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 ...
tomwassing's user avatar
1 vote
1 answer
461 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 ...
Joncarre's user avatar
  • 281
0 votes
1 answer
24 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://...
fff's user avatar
  • 1
0 votes
1 answer
588 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) ...
disqid's user avatar
  • 13
0 votes
1 answer
82 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 ...
toddash's user avatar
  • 82
2 votes
1 answer
228 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 ...
Can Poyrazoğlu's user avatar
0 votes
1 answer
745 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/...
vasik's user avatar
  • 51
1 vote
1 answer
1k 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 ...
Rupesh singh Rathore's user avatar