pub struct AleoHttpClient {
pub base_url: String,
/* private fields */
}Expand description
HTTP client with browser-like headers for Aleo network interaction.
Fields§
§base_url: StringBase URL for REST endpoints (e.g. https://api.explorer.provable.com/v2/testnet)
Implementations§
Source§impl AleoHttpClient
impl AleoHttpClient
Sourcepub fn new(base_url: &str) -> Result<Self>
pub fn new(base_url: &str) -> Result<Self>
Create a new client pointing at an Aleo node (default RPC endpoint).
Sourcepub fn new_with_rpc(base_url: &str, rpc_url: &str) -> Result<Self>
pub fn new_with_rpc(base_url: &str, rpc_url: &str) -> Result<Self>
Create a client with a custom RPC URL (useful for testing with wiremock).
Sourcepub async fn fetch_program(
&self,
program_id: &str,
) -> Result<Program<TestnetV0>>
pub async fn fetch_program( &self, program_id: &str, ) -> Result<Program<TestnetV0>>
Fetch a program from the network (REST GET).
Sourcepub async fn fetch_state_root(
&self,
) -> Result<(<TestnetV0 as Network>::StateRoot, u32)>
pub async fn fetch_state_root( &self, ) -> Result<(<TestnetV0 as Network>::StateRoot, u32)>
Fetch latest state root + block height (REST GET).
Sourcepub async fn broadcast_transaction(&self, tx_json: String) -> Result<String>
pub async fn broadcast_transaction(&self, tx_json: String) -> Result<String>
Broadcast a JSON-serialized transaction (REST POST).
Sourcepub async fn fetch_transaction(&self, tx_id: &str) -> Result<String>
pub async fn fetch_transaction(&self, tx_id: &str) -> Result<String>
Fetch a transaction by its ID from the explorer API. Returns the raw JSON response as a String.
Sourcepub async fn wait_for_confirmation(&self, tx_id: &str) -> Result<()>
pub async fn wait_for_confirmation(&self, tx_id: &str) -> Result<()>
Poll for confirmation (up to 30 attempts, 5s apart).
Sourcepub async fn fetch_mapping_value_rest(
&self,
program_id: &str,
mapping_name: &str,
key: &str,
) -> Result<Option<u64>>
pub async fn fetch_mapping_value_rest( &self, program_id: &str, mapping_name: &str, key: &str, ) -> Result<Option<u64>>
Query a mapping value via REST API (GET /program/{id}/mapping/{name}/{key}).
Returns None if the key does not exist (404).
Sourcepub async fn fetch_mapping_value(
&self,
program_id: &str,
mapping_name: &str,
key: &str,
) -> Result<Option<String>>
pub async fn fetch_mapping_value( &self, program_id: &str, mapping_name: &str, key: &str, ) -> Result<Option<String>>
Query a mapping value via JSON-RPC getMappingValue.
Returns None if the key does not exist in the mapping.
Sourcepub async fn fetch_block_height(&self) -> Result<u32>
pub async fn fetch_block_height(&self) -> Result<u32>
Fetch the current block height (REST GET).
Sourcepub async fn fetch_state_root_only(
&self,
) -> Result<<TestnetV0 as Network>::StateRoot>
pub async fn fetch_state_root_only( &self, ) -> Result<<TestnetV0 as Network>::StateRoot>
Fetch latest state root only (REST GET).
Sourcepub async fn fetch_records(&self, view_key: &str) -> Result<String>
pub async fn fetch_records(&self, view_key: &str) -> Result<String>
Fetch unspent records by view key via JSON-RPC.
Sourcepub async fn fetch_all_records(
&self,
start: u32,
end: u32,
page: u32,
per_page: u32,
) -> Result<Value>
pub async fn fetch_all_records( &self, start: u32, end: u32, page: u32, per_page: u32, ) -> Result<Value>
Fetch all records within a block range via JSON-RPC records/all.
Returns raw record ciphertexts that must be decrypted with a view key.
Sourcepub async fn find_private_credits_records(
&self,
view_key: &str,
) -> Result<Vec<(String, u64)>>
pub async fn find_private_credits_records( &self, view_key: &str, ) -> Result<Vec<(String, u64)>>
Find unspent credits.aleo record ciphertexts owned by the given view key.
Scans recent blocks via records/all, decrypts each record, and returns
those containing credits.aleo with the owner matching the view key’s address.
Trait Implementations§
Source§impl Clone for AleoHttpClient
impl Clone for AleoHttpClient
Auto Trait Implementations§
impl !RefUnwindSafe for AleoHttpClient
impl !UnwindSafe for AleoHttpClient
impl Freeze for AleoHttpClient
impl Send for AleoHttpClient
impl Sync for AleoHttpClient
impl Unpin for AleoHttpClient
impl UnsafeUnpin for AleoHttpClient
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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