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 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 account requirements 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§

accounts
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.
error
events
instruction
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.
orao_vrf
program
Module representing the program.
state

Structs§

FulfillDeprecated
(deprecated: see crate::FulfillV2) Fulfill randomness.
FulfillBuildersdk
crate::Fulfill/crate::FulfillV2 instruction builder.
FulfillBumps
FulfillV2
Fulfill randomness (v2).
FulfillV2Bumps
InitBuildersdk
crate::InitNetwork instruction builder.
InitNetwork
Initialize network configuration.
InitNetworkBumps
RequestDeprecated
(deprecated: see crate::RequestV2) Request randomness.
RequestBuildersdk
crate::RequestV2 instruction builder.
RequestBumps
RequestV2
Request randomness.
RequestV2Bumps
UpdateBuildersdk
crate::UpdateNetwork instruction builder.
UpdateNetwork
Update network configuration.
UpdateNetworkBumps

Enums§

Event
Convenience wrapper.
WaitFulfilledError
An errors associated with the wait_fulfilled function.

Constants§

CONFIG_ACCOUNT_SEED
This is the seed used to create network-wide configuration PDA account, that sets things like fulfillment authorities, costs, etc.
ID_CONST
Const version of ID
MAX_FULFILLMENT_AUTHORITIES_COUNT
RANDOMNESS_ACCOUNT_SEED
This is the seed used for creating request/fulfillment accounts.
VERSION

Statics§

ID
The static program ID

Functions§

check_id
Confirms that a given pubkey is equivalent to the program ID
entry
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.
get_network_statesdk
Fetches VRF on-chain state.
get_randomnesssdk
Fetches randomness request state for the given seed.
id
Returns the program ID
id_const
Const version of ID
majority
Helper that returns the majority for the given total value.
network_state_account_address
Returns network state account address for the given VRF address.
quorum
Helper that checks for Byzantine quorum.
randomness_account_address
Returns randomness account address for the given seed and VRF address.
wait_fulfilledsdk
Waits for the given randomness request to be fulfilled.
xor_array
Helper that XORes r into l.