0x8cC9C2e145d3AA946502964B1B69CE3cD066A9C7. This address is the first 20 bytes of
sha256("Thunder_Random"). Each invocation of fallback function of trusted random generator pre-compiled contract will return a 256-bit rnadom number. The gas cost for each invocation is
26134. The invocation is the same as calling Ethereum pre-compiled contracts. Below is an example which can be embedded into a smart contract. ThunderCore also provides a library which can be sued in Remix with
import "github.com/thundercore/RandomLibrary/RandomLibrary.solfrom Github with URL in Remix. The random number generator will always return a
bytes32value, so you will need to cast or convert this value as it suits your needs.
require(msg.sender == tx.origin)check in
bet()is necessary for security and explained below.
msg.sender (address): sender of the message (current call)
tx.origin (address): sender of the transaction (full call chain)