Questions tagged [randomness]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
19 views

How does randomBytes or extra entropy effect in wallet generation using ethers?

I'm trying to generate new wallet using ethers.js From the examples I got online, randomBytes(16) is used. I wonder if I put randomBytes(128) make any difference. Does it make the wallet generation ...
bbnn's user avatar
  • 236
1 vote
0 answers
55 views

How to Implement Chainlink VRF into EIP2535 Standard Contract

I'm currently working on a smart contract that involves using Chainlink VRF (Verifiable Random Function) through a Diamond contract. My contract structure includes a performUpkeep function, which ...
PraveenMatheesha's user avatar
0 votes
2 answers
188 views

Can PREVRANDAO be written as a random number on chain?

When Ethereum became 2.0, the block difficulty was changed to PREVRANDAO by EIP-4399. We know that PREVRANDAO is a smart contract feature that generates a random number called RANDAO, which is used by ...
imelon2's user avatar
  • 498
0 votes
0 answers
11 views

Safe, Secure, Random Number using only Vyper smart contracts (NO CHAINLINK VRF)

For the purposes of my gaming project I am ditching chainlink VRF in order to obtain a random number because honestly... I hate everything about chainlink. Paying .1 link for a random number is absurd ...
Jack Vafi's user avatar
2 votes
1 answer
16 views

Is it profitable for a miner to manipulate blocks in a small Ethereum project?

In the context of my blockchain project, I’m using the blockhash() function to generate randomness. However, I’m concerned about the potential vulnerability of this method. I’d like to know if, in a ...
Vlad's user avatar
  • 21
0 votes
0 answers
176 views

How to know in a deterministic way if a specifc address is vulnerable to the profanity hack?

Context : My private key just got stolen. The thieve sent to me a message starting by ”nice payment for your work„ on https://chat.blockscan.com along an e‑mail from [email protected] revealing a ...
user2284570's user avatar
  • 1,008
0 votes
1 answer
41 views

Psuedorandom generator sourced from onchain entropy

I'm writing a fun game as a solidity contract and looking to generate somewhat random (or unpredictable numbers). I have researched this topic and am aware using an off chain oracle is the best ...
user avatar
0 votes
0 answers
30 views

Why did Ethereum choose RANDAO rather than VRF for PoS?

I think RANDAO and VRF have different pros and cons for constructing a random number. And I read that RANDAO is very useful when it comes with VDF. But RANDAO is currently adapted without VDF (but ...
Suhyeon's user avatar
1 vote
0 answers
42 views

Creating a sufficiently random number via computation entropy without an oracle

I am creating a token that requires a sufficiently random number for an internal lottery. uint randomX; function semirandomize(uint prevRandom, uint time) private view returns (uint) { ...
Ashraile's user avatar
0 votes
2 answers
52 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
32 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
111 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
68 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
153 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
167 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
100 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
62 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
4 votes
2 answers
5k 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
  • 333
0 votes
1 answer
146 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
  • 345
1 vote
2 answers
166 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
1 answer
219 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
82 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
374 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
36 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
2 votes
1 answer
131 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
  • 301
2 votes
1 answer
171 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
1k 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
478 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
69 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
468 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
98 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
151 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
354 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
  • 870
2 votes
1 answer
187 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
  • 323
0 votes
1 answer
243 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
445 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
418 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
269 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
30 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
404 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
160 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
189 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
65 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
  • 379
1 vote
2 answers
73 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
5 votes
1 answer
961 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,624
0 votes
1 answer
231 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
290 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
21 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