How to generate a random number in solidity?

Solidity contracts are deterministic. Anyone who figures out how your contract produces randomness can anticipate its results and use this information to exploit your application. One option is to produce randomness off-chain (where it cannot be predicted) and use it in your smart contract. Chainlink VRF is an easy-to-implement solution for using random data in … Read more

How can I return an array of struct in solidity?

As you mentioned, this is not yet supported in Solidity. The powers that be are planning on changing it so you can, but for now, you have to retrieve the number of elements and then retrieve the decomposed struct as a tuple. function getBidCount(bytes32 name) public constant returns (uint) { return highestBidder[name].length; } function getBid(bytes32 … Read more