Switchboard commit-reveal randomness. This account type controls commit-reveal style randomness employing Intel SGX enclaves as a randomness security mechanism. For this flow, a user must commit to a future slot that would be unknown to all parties at the time of commitment. The user must then reveal the randomness by then sending the future slot hash to the oracle which can then be signed by the secret key secured within the Trusted Execution Environment.

In this manner, the only way for one to predict the randomness is to:

  1. Have access to the randomness oracle
  2. have control of the solana network slot leader at the time of commit
  3. Have an unpatched Intel SGX vulnerability/advisory that the Switchboard protocol failed to auto-prune.

Constructors

  • Constructs a Randomness instance.

    Parameters

    • program: Program

      The Anchor program instance.

    • pubkey: PublicKey

      The public key of the randomness account.

    Returns Randomness

Properties

program: Program
pubkey: PublicKey

Methods

  • Commit and reveal randomness in a single transaction.

    Parameters

    • callback: TransactionInstruction[]

      The callback to execute after the reveal in the same transaction.

    • signers: Keypair[]

      The signers to sign the transaction.

    • queue: PublicKey

      The queue public key.

    • Optionalconfigs: { computeUnitLimit?: number; computeUnitPrice?: number }

      The configuration options.

      • OptionalcomputeUnitLimit?: number

        The compute unit limit.

      • OptionalcomputeUnitPrice?: number

        The price per compute unit in microlamports.

    • Optionaldebug: boolean

    Returns Promise<void>

    A promise that resolves when the transaction is confirmed.

  • Generate a randomness commit solana transaction instruction. This will commit the randomness account to use currentSlot + 1 slothash as the non-repeating randomness seed.

    Parameters

    • queue: PublicKey

      The queue public key for the commit instruction.

    • Optionalauthority_: PublicKey

      The optional authority public key.

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Loads the randomness data for this Randomness account from on chain.

    Returns Promise<any>

    A promise that resolves to the randomness data.

    Will throw an error if the randomness account does not exist.

  • Generate a randomness reveal solana transaction instruction. This will reveal the randomness using the assigned oracle.

    Parameters

    • Optionalpayer_: PublicKey

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Creates a new Randomness account.

    Parameters

    • program: Program

      The Anchor program instance.

    • kp: Keypair

      The keypair of the new Randomness account.

    • queue: PublicKey

      The queue account to associate with the new Randomness account.

    • Optionalpayer_: PublicKey

      The payer for the transaction. If not provided, the default payer from the program provider is used.

    Returns Promise<[Randomness, TransactionInstruction]>

    A promise that resolves to a tuple containing the new Randomness account and the transaction instruction.

  • Creates a new Randomness account and prepares a commit transaction instruction.

    Parameters

    • program: Program

      The Anchor program instance.

    • queue: PublicKey

      The queue account to associate with the new Randomness account.

    • Optionalpayer_: PublicKey

    Returns Promise<[Randomness, Keypair, TransactionInstruction[]]>

    A promise that resolves to a tuple containing the new Randomness instance, the keypair, and an array of transaction instructions.