pub struct SuiClient { /* private fields */ }client only.Expand description
SuiClient is the basic type that provides all the necessary abstractions for interacting with the Sui network.
§Usage
Use SuiClientBuilder to build a SuiClient.
Implementations§
Source§impl SuiClient
impl SuiClient
pub fn builder() -> SuiClientBuilder
Sourcepub fn available_rpc_methods(&self) -> &Vec<String>
pub fn available_rpc_methods(&self) -> &Vec<String>
Returns a list of RPC methods supported by the node the client is connected to.
Sourcepub fn available_subscriptions(&self) -> &Vec<String>
pub fn available_subscriptions(&self) -> &Vec<String>
Returns a list of streaming/subscription APIs supported by the node the client is connected to.
Sourcepub fn api_version(&self) -> &str
pub fn api_version(&self) -> &str
Returns the API version information as a string.
The format of this string is <major>.<minor>.<patch>, e.g., 1.6.0,
and it is retrieved from the OpenRPC specification via the discover service method.
Sourcepub fn check_api_version(&self) -> SuiClientResult<()>
pub fn check_api_version(&self) -> SuiClientResult<()>
Verifies if the API version matches the server version and returns an error if they do not match.
Sourcepub fn http(&self) -> &HttpClient
pub fn http(&self) -> &HttpClient
Returns a reference to the underlying http client.
Sourcepub fn ws(&self) -> Option<&WsClient>
pub fn ws(&self) -> Option<&WsClient>
Returns a reference to the underlying WebSocket client, if any.
pub async fn get_imm_or_owned_oarg( &self, id: ObjectId, ) -> SuiClientResult<ObjectArg>
Sourcepub async fn multi_get_objects<I>(
&self,
object_ids: I,
options: SuiObjectDataOptions,
) -> SuiClientResult<Vec<SuiObjectResponse>>
pub async fn multi_get_objects<I>( &self, object_ids: I, options: SuiObjectDataOptions, ) -> SuiClientResult<Vec<SuiObjectResponse>>
Return the object data for a list of objects.
This method works for any number of object ids.
Sourcepub async fn select_coins(
&self,
address: SuiAddress,
coin_type: Option<String>,
amount: u64,
exclude: Vec<ObjectId>,
) -> SuiClientResult<Vec<Coin>>
pub async fn select_coins( &self, address: SuiAddress, coin_type: Option<String>, amount: u64, exclude: Vec<ObjectId>, ) -> SuiClientResult<Vec<Coin>>
Return a list of coins for the given address, or an error upon failure.
Note that the function selects coins to meet or exceed the requested amount.
If that it is not possible, it will fail with an insufficient fund error.
The coins can be filtered by coin_type (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC)
or use None to use the default Coin<SUI>.
§Examples
use sui_jsonrpc::client::SuiClientBuilder;
use af_sui_types::Address as SuiAddress;
#[tokio::main]
async fn main() -> color_eyre::Result<()> {
let sui = SuiClientBuilder::default().build_localnet().await?;
let address = "0x0000....0000".parse()?;
let coins = sui
.select_coins(address, None, 5, vec![])
.await?;
Ok(())
}Sourcepub async fn gas_budget(
&self,
tx_kind: &TransactionKind,
sender: SuiAddress,
price: u64,
) -> Result<u64, DryRunError>
pub async fn gas_budget( &self, tx_kind: &TransactionKind, sender: SuiAddress, price: u64, ) -> Result<u64, DryRunError>
Estimate a budget for the transaction by dry-running it.
Uses default GasBudgetOptions to compute the cost estimate.
Sourcepub async fn gas_budget_with_options(
&self,
tx_kind: &TransactionKind,
sender: SuiAddress,
options: GasBudgetOptions,
) -> Result<u64, DryRunError>
pub async fn gas_budget_with_options( &self, tx_kind: &TransactionKind, sender: SuiAddress, options: GasBudgetOptions, ) -> Result<u64, DryRunError>
Estimate a budget for the transaction by dry-running it.
Sourcepub async fn get_gas_data(
&self,
tx_kind: &TransactionKind,
sponsor: SuiAddress,
budget: u64,
price: u64,
) -> Result<GasData, GetGasDataError>
pub async fn get_gas_data( &self, tx_kind: &TransactionKind, sponsor: SuiAddress, budget: u64, price: u64, ) -> Result<GasData, GetGasDataError>
Build the gas data for a transaction by querying the node for gas objects.
Sourcepub async fn latest_object_ref(
&self,
object_id: ObjectId,
) -> SuiClientResult<ObjectRef>
pub async fn latest_object_ref( &self, object_id: ObjectId, ) -> SuiClientResult<ObjectRef>
Get the latest object reference for an ID from the node.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SuiClient
impl !RefUnwindSafe for SuiClient
impl Send for SuiClient
impl Sync for SuiClient
impl Unpin for SuiClient
impl !UnwindSafe for SuiClient
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