docs.rs failed to build sbod_staging4-0.1.5
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
switchboard-solana
A Rust library to interact with Switchboard accounts on Solana.
Install
Run the following Cargo command in your project directory:
Or add the following line to your Cargo.toml:
[]
= "0.29"
NOTE: The minor version corresponds to the anchor-lang dependency. Version 0.29.*
of this crate uses anchor-lang 0.29.0
while version 0.27.*
of this crate uses anchor-lang 0.27.0
. We currently support Anchor 29, 28, and 27.
Accounts
This SDK provides the following account definitions for the Oracle Program:
This SDK provides the following account definitions for the Attestation Program:
Usage
Functions
You will need to validate your function's enclave_signer before allowing your program to modify its state.
use FunctionAccountData;
Aggregator
Read Latest Result
use clock;
use TryInto;
use ;
// check feed owner
let owner = *aggregator.owner;
if owner != SWITCHBOARD_PROGRAM_ID
// deserialize account info
let feed = ctx.accounts.aggregator.load?;
// OR
let feed = new?;
// get result
let decimal: f64 = feed.get_result?.try_into?;
// check if feed has been updated in the last 5 minutes
feed.check_staleness?;
// check if feed exceeds a confidence interval of +/i $0.80
feed.check_confidence_interval?;
Read Aggregator History
Note: The Aggregator must have a history buffer initialized before using
use AggregatorHistoryBuffer;
use TryInto;
let history_buffer = new?;
let current_timestamp = get?.unix_timestamp;
let one_hour_ago: f64 = history_buffer.lower_bound.unwrap.try_into?;
VRF Account
Read VRF Result
use VrfAccountData;
// deserialize the account info
let vrf = ctx.accounts.vrf.load?;
// OR
let vrf = new?;
// read the result
let result_buffer = vrf.get_result?;
let value: & = cast_slice;
let result = value % 256000 as u128;
RequestRandomness CPI
pub use ;
let switchboard_program = ctx.accounts.switchboard_program.to_account_info;
let vrf_request_randomness = VrfRequestRandomness ;
let vrf_key = ctx.accounts.vrf.key.clone;
let authority_key = ctx.accounts.authority.key.clone;
let state_seeds: & = &;
msg!;
vrf_request_randomness.invoke_signed?;