pub struct ThorNode {
pub base_url: Url,
pub chain_tag: u8,
}
Expand description
A simple HTTP REST client for a VeChain node.
Fields§
§base_url: Url
API base url
chain_tag: u8
Chain tag used for this network.
Implementations§
Source§impl ThorNode
impl ThorNode
Sourcepub const MAINNET_CHAIN_TAG: u8 = 74u8
pub const MAINNET_CHAIN_TAG: u8 = 74u8
Chain tag for mainnet
Sourcepub const MAINNET_BASE_URL: &'static str = "https://mainnet.vecha.in/"
pub const MAINNET_BASE_URL: &'static str = "https://mainnet.vecha.in/"
REST API URL for mainnet (one possible)
Sourcepub const TESTNET_CHAIN_TAG: u8 = 39u8
pub const TESTNET_CHAIN_TAG: u8 = 39u8
Chain tag for testnet
Sourcepub const TESTNET_BASE_URL: &'static str = "https://testnet.vecha.in/"
pub const TESTNET_BASE_URL: &'static str = "https://testnet.vecha.in/"
REST API URL for testnet (one possible)
Sourcepub async fn fetch_transaction(
&self,
transaction_id: U256,
) -> AResult<Option<(Transaction, Option<TransactionMeta>)>>
pub async fn fetch_transaction( &self, transaction_id: U256, ) -> AResult<Option<(Transaction, Option<TransactionMeta>)>>
Retrieve a Transaction
from node by its ID.
Returns None
for nonexistent transactions.
Meta can be None
if a transaction was broadcasted, but
not yet included into a block.
This method exists for interoperability with Transaction
from other parts of library. You can get more info from node
with ThorNode::fetch_extended_transaction
.
Sourcepub async fn fetch_extended_transaction(
&self,
transaction_id: U256,
) -> AResult<Option<(ExtendedTransaction, Option<TransactionMeta>)>>
pub async fn fetch_extended_transaction( &self, transaction_id: U256, ) -> AResult<Option<(ExtendedTransaction, Option<TransactionMeta>)>>
Retrieve a Transaction
from node by its ID.
Returns None
for nonexistent transactions.
Meta can be None
if a transaction was broadcasted, but
not yet included into a block.
This method returns more data than ThorNode::fetch_transaction
,
but is not interoperable with Transaction
.
Sourcepub async fn fetch_transaction_receipt(
&self,
transaction_id: U256,
) -> AResult<Option<(Receipt, ReceiptMeta)>>
pub async fn fetch_transaction_receipt( &self, transaction_id: U256, ) -> AResult<Option<(Receipt, ReceiptMeta)>>
Retrieve a transaction receipt from node given a transaction ID.
Returns None
for nonexistent or not mined transactions.
Sourcepub async fn fetch_block(
&self,
block_ref: BlockReference,
) -> AResult<Option<(BlockInfo, Vec<U256>)>>
pub async fn fetch_block( &self, block_ref: BlockReference, ) -> AResult<Option<(BlockInfo, Vec<U256>)>>
Retrieve a block from node by given identifier.
Returns None
for nonexistent blocks.
Sourcepub async fn fetch_best_block(&self) -> AResult<(BlockInfo, Vec<U256>)>
pub async fn fetch_best_block(&self) -> AResult<(BlockInfo, Vec<U256>)>
Retrieve a best block from node.
Sourcepub async fn fetch_block_expanded(
&self,
block_ref: BlockReference,
) -> AResult<Option<(BlockInfo, Vec<BlockTransaction>)>>
pub async fn fetch_block_expanded( &self, block_ref: BlockReference, ) -> AResult<Option<(BlockInfo, Vec<BlockTransaction>)>>
Retrieve a block from node by given identifier together with extended transaction details.
Returns None
for nonexistent blocks.
Sourcepub async fn broadcast_transaction(
&self,
transaction: &Transaction,
) -> AResult<U256>
pub async fn broadcast_transaction( &self, transaction: &Transaction, ) -> AResult<U256>
Broadcast a new Transaction
to the node.
Sourcepub async fn fetch_account(&self, address: Address) -> AResult<AccountInfo>
pub async fn fetch_account(&self, address: Address) -> AResult<AccountInfo>
Retrieve account details.
Sourcepub async fn fetch_account_code(
&self,
address: Address,
) -> AResult<Option<Bytes>>
pub async fn fetch_account_code( &self, address: Address, ) -> AResult<Option<Bytes>>
Retrieve account code.
Returns None
for non-contract accounts.
Sourcepub async fn fetch_account_storage(
&self,
address: Address,
key: U256,
) -> AResult<U256>
pub async fn fetch_account_storage( &self, address: Address, key: U256, ) -> AResult<U256>
Retrieve account storage at key.
Returns None
for non-contract accounts or for missing storage keys.
Sourcepub async fn simulate_execution(
&self,
request: SimulateCallRequest,
) -> AResult<Vec<SimulateCallResponse>>
pub async fn simulate_execution( &self, request: SimulateCallRequest, ) -> AResult<Vec<SimulateCallResponse>>
Simulate a transaction execution.
This is an equivalent of eth_call and can be used to call pure
and
view
functions without broadcasting a transaction. See
[eth_call
] for a better interface
Sourcepub async fn eth_call_advanced(
&self,
request: EthCallRequest,
block_ref: BlockReference,
) -> AResult<Vec<SimulateCallResponse>>
pub async fn eth_call_advanced( &self, request: EthCallRequest, block_ref: BlockReference, ) -> AResult<Vec<SimulateCallResponse>>
Call a pure
or view
function as defined by clause.data
,
possibly providing additional options.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThorNode
impl RefUnwindSafe for ThorNode
impl Send for ThorNode
impl Sync for ThorNode
impl Unpin for ThorNode
impl UnwindSafe for ThorNode
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
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