Skip to main content

Crate orao_solana_vrf

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:

§Crate features

  • sdk (default) – the off-chain client built on anchor-client
  • cpi – on-chain integration (CPI) for Anchor programs
  • solana-v4 (default) / solana-v3 – the Solana crate cohort, mirroring the features of anchor-lang 1.2: enable the one your anchor-lang uses. With cpi alone the crate follows the cohort your program enables on anchor-lang.
# off-chain client on Anchor's default (`solana-v3`) cohort
orao-solana-vrf = { version = "0.8.1", default-features = false, features = ["sdk", "solana-v3"] }
# on-chain CPI, cohort taken from your `anchor-lang`
orao-solana-vrf = { version = "0.8.1", default-features = false, features = ["cpi"] }

§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 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(ctx.accounts.vrf.key(), 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 specifying 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§

Eventsdk
Convenience wrapper.
WaitFulfilledErrorsdk and non-idl-build
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.
ED25519_PROGRAM_ID
The Ed25519 program (Ed25519SigVerify111111111111111111111111111).
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.
new_ed25519_instructionsdk and non-idl-build
Builds the Ed25519 program instruction that verifies message signed by keypair.
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.