Crate orao_solana_vrf

source ·
Expand description

ORAO VRF

Crate to interact with orao-vrf smart contract on Solana network.

Provides an interface to request for a verifiable randomness (Ed25519 Signature) on the Solana network.

Documentation

Please look into the following functions and structures:

Cross Program Invocation

For CPI please look into the cpi example and accouns requiremens for the Request instruction.

Note: requires cpi feature to be enabled and sdk feature to be disabled.

// assuming ctx to be a context of an instruction that performs CPI
let vrf_program = ctx.accounts.vrf.to_account_info();
let request_accounts = orao_solana_vrf::cpi::accounts::Request {
    payer: ctx.accounts.player.to_account_info(),
    network_state: ctx.accounts.config.to_account_info(),
    treasury: ctx.accounts.treasury.to_account_info(),
    request: ctx.accounts.request.to_account_info(),
    system_program: ctx.accounts.system_program.to_account_info(),
};
let cpi_ctx = CpiContext::new(vrf_program, request_accounts);
orao_solana_vrf::cpi::request(cpi_ctx, seed)?;

Re-exports

pub use crate::error::Error;

Modules

An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is a Pubkey. This is useful for specifying accounts for a client.
An Anchor generated module containing the program’s set of instructions, where each method handler in the #[program] mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client.
Module representing the program.

Structs

Fulfill randomness.
fulfill instruction builder.
init_network instruction builder.
Initialize network configuration.
Request randomness.
request instruction builder.
update_network instruction builder.
Update network configuration.

Constants

This is the seed used for creating network-wide configuration PDA account, that sets things like fulfillment authorities, costs, etc.
This is the seed used for creating request/fulfillment accounts.

Statics

The static program ID

Functions

Confirms that a given pubkey is equivalent to the program ID
The Anchor codegen exposes a programming model where a user defines a set of methods inside of a #[program] module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana.
Fetches VRF on-chain state.
Fetches randomness request state for the given seed.
Returns the program ID
Returns network state account address.
Helper that checks for Byzantine quorum.
Returns randomness account address for the given seed.
Helper that XORes r into l.