Skip to main content

ArchRpcClient

Struct ArchRpcClient 

Source
pub struct ArchRpcClient {
    pub config: Config,
    /* private fields */
}
Expand description

ArchRpcClient provides a simple interface for making RPC calls to the Arch blockchain

Fields§

§config: Config

Implementations§

Source§

impl ArchRpcClient

Source

pub fn new(config: &Config) -> Self

Create a new ArchRpcClient with the specified URL

Source

pub fn new_tcp(config: &Config, addr: String) -> Result<Self>

Create a new ArchRpcClient with the specified TCP server address.

Source

pub async fn call_method<R: DeserializeOwned>( &self, method: &str, ) -> Result<Option<R>>

Make a raw RPC call with no parameters and parse the result Returns None if the item was not found (404)

Source

pub async fn call_method_with_params<T: Serialize + Debug, R: DeserializeOwned>( &self, method: &str, params: T, ) -> Result<Option<R>>

Make a raw RPC call with parameters and parse the result Returns None if the item was not found (404)

Source

pub async fn call_method_raw(&self, method: &str) -> Result<Option<Value>>

Get raw value from a method call Returns None if the item was not found (404)

Source

pub async fn call_method_with_params_raw<T: Serialize + Debug>( &self, method: &str, params: T, ) -> Result<Option<Value>>

Get raw value from a method call with parameters Returns None if the item was not found (404)

Source

pub async fn read_account_info(&self, pubkey: Pubkey) -> Result<AccountInfo>

Read account information for the specified public key

Source

pub async fn get_multiple_accounts( &self, pubkeys: Vec<Pubkey>, ) -> Result<Vec<Option<AccountInfoWithPubkey>>>

Read account information for multiple public keys

Source

pub async fn request_airdrop( &self, pubkey: Pubkey, ) -> Result<ProcessedTransaction>

Request an airdrop for a given public key

Source

pub async fn create_and_fund_account_with_faucet( &self, keypair: &Keypair, ) -> Result<()>

Create an account with lamports

Source

pub async fn get_processed_transaction( &self, tx_id: &Hash, ) -> Result<Option<ProcessedTransaction>>

Get a processed transaction by ID

Source

pub async fn get_full_block_with_txids( &self, block_id: &Hash, ) -> Result<(Block, Vec<ProcessedTransaction>)>

Get a block with its transactions by ID

Source

pub async fn wait_for_processed_transaction( &self, tx_id: &Hash, ) -> Result<ProcessedTransaction>

Waits for a transaction to be processed, polling until it reaches “Processed” or “Failed” status. Will timeout after 60 seconds of wall-clock time.

Source

pub async fn wait_for_processed_transactions( &self, tx_ids: Vec<Hash>, ) -> Result<Vec<ProcessedTransaction>>

Waits for multiple transactions to be processed, showing progress with a progress bar Returns a vector of processed transactions in the same order as the input transaction IDs

Source

pub async fn get_transaction_status( &self, tx_ids: Vec<Hash>, ) -> Result<Vec<Result<Status>>>

Source

pub async fn get_best_block_hash(&self) -> Result<Hash>

Get the best block hash

Source

pub async fn get_best_finalized_block_hash(&self) -> Result<Hash>

Get the best finalized block hash

Source

pub async fn get_block_hash(&self, block_height: u64) -> Result<String>

Get the block hash for a given height

Source

pub async fn get_block_count(&self) -> Result<u64>

Get the current block count

Source

pub async fn get_block_by_hash(&self, block_hash: &str) -> Result<Option<Block>>

Get block by hash with signatures only

Source

pub async fn get_full_block_by_hash( &self, block_hash: &str, ) -> Result<Option<FullBlock>>

Get full block by hash with complete transaction details

Source

pub async fn get_block_by_height( &self, block_height: u64, ) -> Result<Option<Block>>

Get block by height with signatures only

Source

pub async fn get_full_block_by_height( &self, block_height: u64, ) -> Result<Option<FullBlock>>

Get full block by height with complete transaction details

Source

pub async fn get_account_address(&self, pubkey: &Pubkey) -> Result<String>

Get account address for a public key

Source

pub async fn get_program_accounts( &self, program_id: &Pubkey, filters: Option<Vec<AccountFilter>>, ) -> Result<Vec<ProgramAccount>>

Get program accounts for a given program ID

Source

pub async fn check_pre_anchor_conflict( &self, accounts: Vec<Pubkey>, ) -> Result<bool>

Source

pub async fn get_network_pubkey(&self) -> Result<String>

Get the network pubkey from the network

Source

pub async fn send_transaction( &self, transaction: RuntimeTransaction, ) -> Result<Hash>

Send a single transaction

Source

pub async fn send_transactions( &self, transactions: Vec<RuntimeTransaction>, ) -> Result<Vec<Hash>>

Send multiple transactions

Source

pub fn process_result(&self, response: String) -> Result<Option<Value>>

Helper methods for RPC communication

Source

pub async fn post_data<T: Serialize + Debug>( &self, method: &str, params: T, ) -> Result<String>

Trait Implementations§

Source§

impl Clone for ArchRpcClient

Source§

fn clone(&self) -> ArchRpcClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more