Struct fuels_accounts::wallet::Wallet
source · pub struct Wallet { /* private fields */ }
Expand description
A FuelVM-compatible wallet that can be used to list assets, balances and more.
Note that instances of the Wallet
type only know their public address, and as a result can
only perform read-only operations.
In order to sign messages or send transactions, a Wallet
must first call Wallet::unlock
with a valid private key to produce a WalletUnlocked
.
Implementations§
source§impl Wallet
impl Wallet
sourcepub fn from_address(address: Bech32Address, provider: Option<Provider>) -> Self
pub fn from_address(address: Bech32Address, provider: Option<Provider>) -> Self
Construct a Wallet from its given public address.
pub fn provider(&self) -> Option<&Provider>
pub fn set_provider(&mut self, provider: Provider) -> &mut Self
pub fn address(&self) -> &Bech32Address
sourcepub fn unlock(self, private_key: SecretKey) -> WalletUnlocked
pub fn unlock(self, private_key: SecretKey) -> WalletUnlocked
Unlock the wallet with the given private_key
.
The private key will be stored in memory until wallet.lock()
is called or until the
wallet is drop
ped.
Trait Implementations§
source§impl ViewOnlyAccount for Wallet
impl ViewOnlyAccount for Wallet
fn address(&self) -> &Bech32Address
fn try_provider(&self) -> Result<&Provider, AccountError>
fn set_provider(&mut self, provider: Provider) -> &mut Wallet
fn get_transactions<'life0, 'async_trait>( &'life0 self, request: PaginationRequest<String> ) -> Pin<Box<dyn Future<Output = Result<PaginatedResult<TransactionResponse, String>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
source§fn get_coins<'life0, 'async_trait>(
&'life0 self,
asset_id: AssetId
) -> Pin<Box<dyn Future<Output = Result<Vec<Coin>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_coins<'life0, 'async_trait>( &'life0 self, asset_id: AssetId ) -> Pin<Box<dyn Future<Output = Result<Vec<Coin>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Gets all unspent coins of asset
asset_id
owned by the account.source§fn get_asset_balance<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 AssetId
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_asset_balance<'life0, 'life1, 'async_trait>( &'life0 self, asset_id: &'life1 AssetId ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Get the balance of all spendable coins
asset_id
for address address
. This is different
from getting coins because we are just returning a number (the sum of UTXOs amount) instead
of the UTXOs.source§fn get_messages<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_messages<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Gets all unspent messages owned by the account.
source§fn get_balances<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_balances<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, u64>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Get all the spendable balances of all assets for the account. This is different from getting
the coins because we are only returning the sum of UTXOs coins amount and not the UTXOs
coins themselves.
fn get_spendable_resources<'life0, 'async_trait>( &'life0 self, asset_id: AssetId, amount: u64 ) -> Pin<Box<dyn Future<Output = Result<Vec<Resource>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for Wallet
impl Send for Wallet
impl Sync for Wallet
impl Unpin for Wallet
impl !UnwindSafe for Wallet
Blanket Implementations§
source§impl<T> AnyDebug for Twhere
T: Any + Debug,
impl<T> AnyDebug for Twhere T: Any + Debug,
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying type as
Any
.