Linked Questions

0
votes
1answer
709 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
394 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!
2
votes
1answer
388 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 ...
2
votes
2answers
236 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
0answers
80 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
53 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 ...
0
votes
0answers
27 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 ...
1
vote
0answers
25 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
15 views

What's the best realized dapps for fair betting without oracles? [duplicate]

Pretty much self-explanatory. I accept all kind of suggestions.
14
votes
5answers
31k 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 ...
20
votes
3answers
5k 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 ...
21
votes
1answer
3k 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). ...
14
votes
3answers
995 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 ...
5
votes
2answers
1k views

How to stop miner who does not execute operations?

When a miner evaluate operations on VM there might be a case when there is not enough gas to fulfill operation. In such cases "The miner will stop processing the transaction, revert any changes ...
6
votes
2answers
2k views

Honest lottery winner generation - pseudo random number obtaining

Suppose I would like to organize a honest lottery and prevent cheating when we need to find a winner. I known problem of random number in the known network arises. I would like to try the following ...

15 30 50 per page