Struct fuels_signers::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 get_provider(&self) -> Result<&Provider, WalletError>
pub fn set_provider(&mut self, provider: Provider)
pub fn address(&self) -> &Bech32Address
pub async fn get_transactions( &self, request: PaginationRequest<String> ) -> Result<PaginatedResult<TransactionResponse, String>>
sourcepub async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
amount: u64,
witness_index: u8
) -> Result<Vec<Input>>
pub async fn get_asset_inputs_for_amount( &self, asset_id: AssetId, amount: u64, witness_index: u8 ) -> Result<Vec<Input>>
Returns a vector consisting of Input::Coin
s and Input::Message
s for the given
asset ID and amount. The witness_index
is the position of the witness (signature)
in the transaction’s list of witnesses. In the validation process, the node will
use the witness at this index to validate the coins returned by this method.
sourcepub fn get_asset_outputs_for_amount(
&self,
to: &Bech32Address,
asset_id: AssetId,
amount: u64
) -> Vec<Output> ⓘ
pub fn get_asset_outputs_for_amount( &self, to: &Bech32Address, asset_id: AssetId, amount: u64 ) -> Vec<Output> ⓘ
Returns a vector containing the output coin and change output given an asset and amount
sourcepub async fn get_coins(&self, asset_id: AssetId) -> Result<Vec<Coin>>
pub async fn get_coins(&self, asset_id: AssetId) -> Result<Vec<Coin>>
Gets all unspent coins of asset asset_id
owned by the wallet.
sourcepub async fn get_spendable_resources(
&self,
asset_id: AssetId,
amount: u64
) -> Result<Vec<Resource>>
pub async fn get_spendable_resources( &self, asset_id: AssetId, amount: u64 ) -> Result<Vec<Resource>>
Get some spendable resources (coins and messages) of asset asset_id
owned by the wallet
that add up at least to amount amount
. The returned coins (UTXOs) are actual coins that
can be spent. The number of UXTOs is optimized to prevent dust accumulation.
sourcepub async fn get_asset_balance(&self, asset_id: &AssetId) -> Result<u64>
pub async fn get_asset_balance(&self, asset_id: &AssetId) -> Result<u64>
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.
sourcepub async fn get_balances(&self) -> Result<HashMap<String, u64>>
pub async fn get_balances(&self) -> Result<HashMap<String, u64>>
Get all the spendable balances of all assets for the wallet. This is different from getting the coins because we are only returning the sum of UTXOs coins amount and not the UTXOs coins themselves.
pub async fn get_messages(&self) -> Result<Vec<InputMessage>>
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§
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)
Any
.