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§
- accounts
- 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. - 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§
- Fulfill
Deprecated - (deprecated: see
crate::FulfillV2
) Fulfill randomness. - Fulfill
Builder sdk
crate::Fulfill
/crate::FulfillV2
instruction builder.- Fulfill
Bumps - Fulfill
V2 - Fulfill randomness (v2).
- Fulfill
V2Bumps - Init
Builder sdk
crate::InitNetwork
instruction builder.- Init
Network - Initialize network configuration.
- Init
Network Bumps - Request
Deprecated - (deprecated: see
crate::RequestV2
) Request randomness. - Request
Builder sdk
crate::RequestV2
instruction builder.- Request
Bumps - Request
V2 - Request randomness.
- Request
V2Bumps - Update
Builder sdk
crate::UpdateNetwork
instruction builder.- Update
Network - Update network configuration.
- Update
Network Bumps
Enums§
- Event
- Convenience wrapper.
- Wait
Fulfilled Error - 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_ state sdk
- Fetches VRF on-chain state.
- get_
randomness sdk
- 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_
fulfilled sdk
- Waits for the given randomness request to be fulfilled.
- xor_
array - Helper that XORes
r
intol
.