pub struct Env { /* private fields */ }Expand description
The environment for Soroban operations.
Provides access to network functionality such as retrieving account information, simulating transactions, and submitting transactions to the network.
Implementations§
Source§impl Env
impl Env
Sourcepub fn new(configs: EnvConfigs) -> Result<Self, SorobanHelperError>
pub fn new(configs: EnvConfigs) -> Result<Self, SorobanHelperError>
Creates a new environment with the specified configuration.
§Parameters
configs- The environment configuration including RPC URL and network passphrase
§Returns
A new Env instance or an error if the RPC client could not be created
§Errors
Returns SorobanHelperError if the RPC client initialization fails
Sourcepub fn network_passphrase(&self) -> &str
pub fn network_passphrase(&self) -> &str
Returns the network passphrase for this environment.
The network passphrase is a string that uniquely identifies a Stellar network, such as “Public Global Stellar Network ; September 2015” for the public network or “Test SDF Network ; September 2015” for the testnet.
§Returns
The network passphrase as a string slice
Sourcepub fn network_id(&self) -> Hash
pub fn network_id(&self) -> Hash
Calculates the network ID hash from the network passphrase.
The network ID is the SHA-256 hash of the network passphrase and is used in various cryptographic operations, including transaction signing.
§Returns
The SHA-256 hash of the network passphrase
Sourcepub async fn get_account(
&self,
account_id: &str,
) -> Result<AccountEntry, SorobanHelperError>
pub async fn get_account( &self, account_id: &str, ) -> Result<AccountEntry, SorobanHelperError>
Sourcepub async fn simulate_transaction(
&self,
tx_envelope: &TransactionEnvelope,
) -> Result<SimulateTransactionResponse, SorobanHelperError>
pub async fn simulate_transaction( &self, tx_envelope: &TransactionEnvelope, ) -> Result<SimulateTransactionResponse, SorobanHelperError>
Simulates a transaction without submitting it to the network.
This is useful for estimating transaction costs, validating transactions, and retrieving the expected results of contract invocations.
§Parameters
tx_envelope- The transaction envelope to simulate
§Returns
The simulation response or an error if the simulation failed
§Errors
Returns SorobanHelperError::NetworkRequestFailed if the RPC request fails
Sourcepub async fn send_transaction(
&self,
tx_envelope: &TransactionEnvelope,
) -> Result<SorobanTransactionResponse, SorobanHelperError>
pub async fn send_transaction( &self, tx_envelope: &TransactionEnvelope, ) -> Result<SorobanTransactionResponse, SorobanHelperError>
Submits a transaction to the network and waits for the result.
§Parameters
tx_envelope- The signed transaction envelope to submit
§Returns
The transaction response or an error if the transaction failed
§Errors
Returns:
SorobanHelperError::ContractCodeAlreadyExistsif the transaction failed because the contract code already existsSorobanHelperError::NetworkRequestFailedfor other transaction failures
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Env
impl !RefUnwindSafe for Env
impl Send for Env
impl Sync for Env
impl Unpin for Env
impl !UnwindSafe for Env
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