Questions tagged [random]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
39 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
1 vote
0 answers
68 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
2 votes
0 answers
142 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
0 votes
1 answer
18 views

Random seed generator algorithm, who can explain this algo to me? is this a good one? what's the design about it?

function generateSeed(uint256 tokenId) public view returns (uint256) { uint256 r = random(tokenId); uint256 headSeed = 100 * (r % 7 + 10) + ((r >> 48) % 20 + 10); uint256 faceSeed = ...
Nick's user avatar
  • 55
0 votes
1 answer
118 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
  • 313
1 vote
0 answers
113 views

Chainlink Random Number generator failing with Gas error

I am trying to generate a random number using chainlink VRF i have changed all the address as per goreli I have deployed in goreli testnet and sent some link token to the contract address Clicking on ...
Sunny's user avatar
  • 11
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
3 answers
427 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
2 votes
1 answer
178 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
1 vote
1 answer
181 views

function call gives me "pending.."

I have a problem with a function in a lottery contract. given that library for pseudorandom: library Random { /* * @dev startingValue is inclusive, endingValue is inclusive * naive implementation! ...
Federico's user avatar
0 votes
1 answer
169 views

Generating Random Number in Solidity is pending

pragma solidity ^0.8.0; uint256 private RandNonce = 0; function RandomNumber() public returns(uint256){ uint256 rand = uint(keccak256(abi.encodePacked(block.timestamp,msg.sender,...
spear dark's user avatar
1 vote
0 answers
150 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
34 views

Generating psuedo-random numbers from a non-verified contract

I understand that since psuedo-randomness in solidity is deterministic, miners and hackers will be able to reverse engineer or manipulate the pieces to force their hand. However, if I had a separate ...
user3238454's user avatar
1 vote
1 answer
56 views

Best way to get notified when fallback arrived

When you request random number, the Chainlink VRF2 returns it by calling following function. function fulfillRandomWords( uint256, /* requestId */ uint256[] memory randomWords ) ...
Emrah's user avatar
  • 1,564
0 votes
1 answer
166 views

Correct way of using Random() Function while using Loops in solidity?

I want to generate a random number several times using a loop. I am currently using block.timestamp logic but it is giving the same number on every iteration. Which is correct I think because the ...
Abdullah Hanif Chaudhary's user avatar
1 vote
1 answer
275 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 ...
saxajeel'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
0 votes
0 answers
100 views

Random DNA mix in Solidity

Hello I have DNA mix function and I am trying to implement random function while mixing DNA for example dad DNA is 10 10 10 10 10 10 10 10 10 10 and mum DNA is 21 21 21 21 21 21 21 21 21 21 and child ...
Dito Khelaia's user avatar
0 votes
0 answers
108 views

Unknown issue in solidity random function

I using this function to generate random numbers (example value of that 3 variables are commented in code below) this code sometimes works and sometimes does not. when I tested with manual value and ...
Dito Khelaia's user avatar
2 votes
1 answer
239 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
354 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. (...
p0pps's user avatar
  • 278
0 votes
2 answers
514 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 ...
Sullivan Xiong's user avatar
0 votes
1 answer
361 views

Generate random nft art from characteristics

What is the best way to generate random art from characteristics? I’m looking into creating profile picture nfts like how wicked craniums, punks and bored bananas are random. Also what is the best way ...
Zap's user avatar
  • 1
1 vote
1 answer
51 views

Would this be a good choice?

Would this pseudo random algorithm be failproof: I'm implementing a lottery contract and the winner is chose by getting addresses of each player who joined , packing the addresses into a string and ...
Ionutz Dinca's user avatar
0 votes
2 answers
2k views

Can you get an array of random numbers?

The question says it all. Can I get an array of random numbers in solidity?
Patrick Collins's user avatar
0 votes
1 answer
54 views

Help to get variable in a pseudo random lottery contract

Hi everyone at the other side! I'm doing a pseudo random lottery contract on solidity. It's working 100% good. The logic of the contract is that a player pays for getting a number in order to match ...
Mario Saavedra Vergara's user avatar
1 vote
1 answer
2k 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 ...
greentriangles1's user avatar
2 votes
1 answer
1k views

Ensuring a fair distribution of an NFT set?

Suppose I have 1000 NFT's I would like to distribute. The user can see what any NFT looks like in advance, but they don't know what they'll be getting until they actually buy it. In other words, there ...
greentriangles1's user avatar
3 votes
2 answers
6k views

Random BigNumber in ethers.js

I'm looking to generate a random ethers.js BigNumber in a certain range. While this question has answers about random number generation, the answers as of this writing (April 2021) only cover BigInt, ...
The Renaissance's user avatar
0 votes
0 answers
353 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 ...
Alexander Herranz's user avatar
1 vote
1 answer
183 views

Call Smart Contract At Unpredictable Time

Is there a call scheduling service that lets you schedule a call at a time in the future not predictable by someone with access to contract code and transaction details? The scheduling services I've ...
qwerty's user avatar
  • 11
0 votes
1 answer
534 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 ...
Manu's user avatar
  • 9
2 votes
2 answers
2k views

Generating random uint256 numbers in JS

I need to generate a uint256 random number offchain (in a Node.js client). Since BN doesn't have a random() function, what's the best way to do so?
Vitor Py's user avatar
  • 143
3 votes
2 answers
4k views

Generating random number in Solidity without Chainlink

Hello I'm well aware there are plenty of threads around discussing different methods. Just curious and wanted to ask directly here because feel like the situation might be different. Essentially I'm ...
Alienbyte's user avatar
0 votes
1 answer
38 views

Proof that a variable is truly random [duplicate]

I have thinking of the wonder that an application could offer if it could prove that some of its data are truly random and so not controlled. Can the ethereum blockchain offer such a service and how ...
Saxtheowl's user avatar
  • 668
0 votes
1 answer
522 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 ...
zak100's user avatar
  • 1,416
1 vote
1 answer
295 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 ...
Imestin's user avatar
  • 35
3 votes
0 answers
24 views

Oraclizer does not respond periodically

Contract that use oraclizer work just fine from moment of deploy. But three days ago oraclizer start to ignore requests of my contract(not allways). In this trx oracle dont return callback, but when ...
Alexandr Ovdienko's user avatar
2 votes
1 answer
359 views

Multiple callbacks with provable random oracle

I'm making a simple lottery game where there are hourly, daily and weekly prizes. My contract has functions to pick winners for each of these game types. Each game types will have different number of ...
koukotsu's user avatar
  • 351