Struct orao_solana_vrf::RequestBuilder
source · pub struct RequestBuilder { /* private fields */ }
sdk
only.Expand description
crate::RequestV2
instruction builder.
Note:
- prioritization fees here are handled automatically based on the recent
prioritization fees — use
RequestBuilder::with_compute_unit_price
to opt-out. - this builder is added for convenience — use
RequestBuilder::into_raw_instruction
to get the raw instruction, or build it yourself (see theRequestBuilder::into_raw_instruction
source)
Example:
use anchor_client::*;
// Feel free to chose the necessary `CommitmentLevel` using `Client::new_with_options`
let client = Client::new(Cluster::Devnet, payer);
let program = client.program(orao_solana_vrf::id())?;
let seed = rand::random();
let mut tx = orao_solana_vrf::RequestBuilder::new(seed)
// use `with_compute_unit_price(..)` function to override
// the default prioritization fee
.build(&program)
.await?
// You can add more instructions to the transaction, if necessary, but we'll send it as is.
.send()
.await?;
println!("Your transaction is {}", tx);
Implementations§
source§impl RequestBuilder
impl RequestBuilder
sourcepub fn new(seed: [u8; 32]) -> Self
pub fn new(seed: [u8; 32]) -> Self
Creates a new builder with the given seed. Fees are paid with lamports by default.
sourcepub fn pay_with_token(self, token_wallet: Pubkey) -> Self
pub fn pay_with_token(self, token_wallet: Pubkey) -> Self
Pay fees with SPL token using given token wallet address.
Instruction could fail if token fee is not configured for the contract.
sourcepub fn with_compute_unit_price(self, compute_unit_price: u64) -> Self
pub fn with_compute_unit_price(self, compute_unit_price: u64) -> Self
Defines a prioritization fee in micro-lamports (applied per compute unit).
Adds ComputeBudgetInstruction::SetComputeUnitPrice
to the request builder.
- if not specified, then median fee of the last 150 confirmed slots is used (this is by default)
- if zero, then compute unit price is not applied at all.
sourcepub fn with_compute_unit_price_multiplier(self, multiplier: f64) -> Self
pub fn with_compute_unit_price_multiplier(self, multiplier: f64) -> Self
Defines a multiplier that is applied to a median compute unit price.
This is only applied if no compute_unit_price specified, i.e. if compute unit price is measured as a median fee of the last 150 confirmed slots.
- if not specified, then no multiplier is applied (this is by default)
- if specified, then applied as follows:
compute_unit_price = median * multiplier
sourcepub fn with_compute_unit_limit(self, compute_unit_limit: u32) -> Self
pub fn with_compute_unit_limit(self, compute_unit_limit: u32) -> Self
Defines a specific compute unit limit that the transaction is allowed to consume.
Adds ComputeBudgetInstruction::SetComputeUnitLimit
to the request builder.
- if not specified, then compute unit limit is not applied at all (this is by default)
- if specified, then applied as is
sourcepub fn into_raw_instruction(
self,
id: Pubkey,
payer: Pubkey,
current_config: NetworkConfiguration,
) -> Option<Instruction>
pub fn into_raw_instruction( self, id: Pubkey, payer: Pubkey, current_config: NetworkConfiguration, ) -> Option<Instruction>
Builds the raw crate::RequestV2
instruction based on this builder.
This is a low-level function, consider using RequestBuilder::build
.
id
— the VRF program id (usually thecrate::id
)payer
— transaction fee payer that will sign the tx.current_config
— is the effective VRF configuration (seecrate::get_network_state
)
Returns None
if RequestBuilder::pay_with_token
is given, but no token fee
configured in the current_config
.
Compute Budget Program configuration is ignored.
sourcepub async fn build<C: Deref<Target = impl Signer> + Clone>(
self,
orao_vrf: &Program<C>,
) -> Result<RequestBuilder<'_, C>, ClientError>
pub async fn build<C: Deref<Target = impl Signer> + Clone>( self, orao_vrf: &Program<C>, ) -> Result<RequestBuilder<'_, C>, ClientError>
Builds the request.
Note that this function returns an anchor_client::RequestBuilder
instance,
so feel free to put more instructions into the request.
Trait Implementations§
source§impl Debug for RequestBuilder
impl Debug for RequestBuilder
source§impl Default for RequestBuilder
impl Default for RequestBuilder
source§fn default() -> RequestBuilder
fn default() -> RequestBuilder
Auto Trait Implementations§
impl Freeze for RequestBuilder
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnwindSafe for RequestBuilder
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more