Skip to content

Onchain Randomness

TODO: Write content for this page.

Generate cryptographically secure random numbers in canisters using the management canister’s raw_rand API. Explain why randomness is hard on blockchains and how ICP solves it with VRF. Use cases: games, lotteries, fair selection. Security considerations: never use randomness in query calls, always use in update calls.

  • Portal: building-apps/integrations/randomness.mdx
  • Examples: random_maze (Motoko)
  • Management canister: raw_rand method
  • concepts/onchain-randomness — VRF-based randomness explained
  • guides/security/data-integrity — randomness and security
  • reference/management-canister — raw_rand API