-2

I am trying to write a guess-the-number game on Solana. I am trying to write a Solana program (smart-contract) where the smart contract randomly picks a random number and whoever guesses it wins. Its a simple hello-world kind of a situation.

Can I make sure that the private secret_integer stays private until someone guesses it.

I am trying to understand if the private integer that randomly picked by the program can be seen on the blockchain explorers.

Marci-man
  • 2,113
  • 3
  • 28
  • 76

1 Answers1

0

You will need to rethink your approach

  1. Random number generation in a program is not supported and you will get an error during compilation of your program if you attempt to include 'rand'
  2. Your program will need to store the secret number in some account data space and by definition it is accessible to the public. Solana is a public blockchain. You would need to do some kind of encryption (both in and out) which will likely suck up Compute Units (CU). Even if you buy more CU for instructions in a transaction, it maxes out at 1M I believe.
Frank C.
  • 7,758
  • 4
  • 35
  • 45