Linked Questions

3
votes
2answers
617 views

Best practices for generating a random uint256 [duplicate]

I've read through this thread and this thread and they offer a lot of interesting techniques, but what's the minimal code snippet for the currently accepted method of generating a random number in ...
3
votes
1answer
464 views

Are future block hashes viable as an RNG? [duplicate]

Let's say I want to make a gambling contract. Anyone can call the createWager function to create a new bet to flip a coin. When they win, in order to collect the payment for the wager, they have to ...
0
votes
1answer
773 views

How to create random number in solidity except sha3? [duplicate]

I am using sha3 to create 3 unique id in a same function. But results are same for all of them because it is using timestamp like this "uint256 random = uint256(sha3(block.timestamp)) +1;". So, I ...
2
votes
1answer
407 views

Random number inside contract [duplicate]

It is possible to generate truly (not pseudo) random number with specific range inside smart contacts (for example I need random number between 1 and 60 000 ) Thx!
1
vote
1answer
139 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?
3
votes
0answers
84 views

Which is the safest way to generate a random number? [duplicate]

I need a function that generates a random number from 0 to n for the lottery. I found 2 ways to do that: 1. https://gist.github.com/alexvandesande/259b4ffb581493ec0a1c But miners can influence the ...
1
vote
0answers
60 views

Oracles and randomness, Creating or solving problems? [duplicate]

The idea behind oracles as a way to outsource information to be off the blockchain (Verifiable computing), Can solve a lot of problems, mostly related to randomness, As well as interacting with other ...
1
vote
0answers
37 views

Solidity effective random number [duplicate]

How can i generate random number in contract? Like this: uint8(uint256(keccak256(block.timestamp, block.difficulty))%251); but we cannot trust miner, this is not 100% random Or use Oraclize: ...
0
votes
0answers
30 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 ...
0
votes
0answers
13 views

Random Number Generation, Appropriate case or no? [duplicate]

I'm building a lottery where I need to generate a list of random numbers. Basically, I have a group of people who will commit to a prize by staking a certain amount of tokens to their commitment - ...
0
votes
0answers
11 views

How do i select a random number from a given range in my contract? [duplicate]

I am trying to create a simple gambling app in which the users are all assigned numbers when they enter the contest and i need to select a winner based on this number. Consider the numbers are 1-100 ...
14
votes
5answers
32k views

Where can I find some Solidity / Smart Contract source code examples? [closed]

Is there an easy to access list of Solidity / Smart Contracts / Dapps source code examples? Related information: Is there a list of DAPPS that are already useable? Where can I learn how to develop ...
25
votes
3answers
6k views

Can a contract safely rely on block.timestamp?

How safe is it to use block.timestamp as contract expiration time? If a miner provides an incorrect timestamp in a block header, how much can it be off before it is rejected by other nodes? Is there a ...
25
votes
1answer
4k views

When can BLOCKHASH be safely used for a random number? When would it be unsafe?

I've seen more complicated ways for a contract to generate a random number. But the Ethereum Yellow Paper itself suggests a "trivial solution" using the BLOCKHASH opcode (see below, bold is mine). ...
16
votes
3answers
1k views

What are effective and secure ways of shuffling a deck of cards in a contract?

We want to write a card game in Ethereum. What are effective and secure ways of shuffling a deck of cards in a contract, and dealing them to players? It needs to be done in a way so that no one can ...

15 30 50 per page