Struct anchor_client::RequestBuilder
source · pub struct RequestBuilder<'a, C> { /* private fields */ }
Expand description
RequestBuilder
provides a builder interface to create and send
transactions to a cluster.
Implementations§
source§impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C>
impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C>
pub fn from( program_id: Pubkey, cluster: &str, payer: C, options: Option<CommitmentConfig> ) -> Self
Available on crate feature
async
only.pub async fn signed_transaction(&self) -> Result<Transaction, ClientError>
Available on crate feature
async
only.pub async fn send(self) -> Result<Signature, ClientError>
Available on crate feature
async
only.pub async fn send_with_spinner_and_config( self, config: RpcSendTransactionConfig ) -> Result<Signature, ClientError>
Available on crate feature
async
only.source§impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C>
impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C>
pub fn payer(self, payer: C) -> Self
pub fn cluster(self, url: &str) -> Self
pub fn instruction(self, ix: Instruction) -> Self
pub fn program(self, program_id: Pubkey) -> Self
sourcepub fn accounts(self, accounts: impl ToAccountMetas) -> Self
pub fn accounts(self, accounts: impl ToAccountMetas) -> Self
Set the accounts to pass to the instruction.
accounts
argument can be:
- Any type that implements
ToAccountMetas
trait - A vector of
AccountMeta
s (for remaining accounts)
Note that the given accounts are appended to the previous list of accounts instead of overriding the existing ones (if any).
§Example
ⓘ
program
.request()
// Regular accounts
.accounts(accounts::Initialize {
my_account: my_account_kp.pubkey(),
payer: program.payer(),
system_program: system_program::ID,
})
// Remaining accounts
.accounts(vec![AccountMeta {
pubkey: remaining,
is_signer: true,
is_writable: true,
}])
.args(instruction::Initialize { field: 42 })
.send()?;
pub fn options(self, options: CommitmentConfig) -> Self
pub fn args(self, args: impl InstructionData) -> Self
pub fn signer(self, signer: &'a dyn Signer) -> Self
pub fn instructions(&self) -> Result<Vec<Instruction>, ClientError>
pub fn transaction(&self) -> Result<Transaction, ClientError>
Auto Trait Implementations§
impl<'a, C> Freeze for RequestBuilder<'a, C>where
C: Freeze,
impl<'a, C> !RefUnwindSafe for RequestBuilder<'a, C>
impl<'a, C> !Send for RequestBuilder<'a, C>
impl<'a, C> !Sync for RequestBuilder<'a, C>
impl<'a, C> Unpin for RequestBuilder<'a, C>where
C: Unpin,
impl<'a, C> !UnwindSafe for RequestBuilder<'a, C>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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