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:
RequestBuilder
– convenient builder for randomness requestsget_network_state
– helper to fetch the VRF configurationget_randomness
– helper to fetch the randomness request staterandomness_account_address
– helper to derive randomness request state addressnetwork_state_account_address
– helper to derive VRF on-chain configuration address
§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§
- An Anchor generated module, providing a set of structs mirroring the structs deriving
Accounts
, where each field is aPubkey
. 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§
- FulfillDeprecated(deprecated: see
crate::FulfillV2
) Fulfill randomness. crate::Fulfill
/crate::FulfillV2
instruction builder.- Fulfill randomness (v2).
- InitBuilder
sdk
crate::InitNetwork
instruction builder. - Initialize network configuration.
- RequestDeprecated(deprecated: see
crate::RequestV2
) Request randomness. crate::RequestV2
instruction builder.- Request randomness (v2).
crate::UpdateNetwork
instruction builder.- Update network configuration.
Enums§
- Event
sdk
Convenience wrapper. - An errors associated with the
wait_fulfilled
function.
Constants§
- This is the seed used to create 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
- Helper that returns the majority for the given total value.
- Returns network state account address for the given VRF address.
- Helper that checks for Byzantine quorum.
- Returns randomness account address for the given seed and VRF address.
- Waits for the given randomness request to be fulfilled.
- Helper that XORes
r
intol
.