pub struct Provider {
    pub client: FuelClient,
}
Expand description

Encapsulates common client operations in the SDK. Note that you may also use client, which is an instance of FuelClient, directly, which provides a broader API.

Fields§

§client: FuelClient

Implementations§

Sends a transaction to the underlying Provider’s client.

Examples
Sending a transaction
use fuels::tx::Script;
use fuels::prelude::*;
async fn foo() -> Result<(), Box<dyn std::error::Error>> {
  // Setup local test node
  let (provider, _) = setup_test_provider(vec![], vec![], None, None).await;
  let tx = Script::default();

  let receipts = provider.send_transaction(&tx).await?;
  dbg!(receipts);

  Ok(())
}

Connects to an existing node at the given address.

Examples
Connect to a node
async fn connect_to_fuel_node() {
    use fuels::prelude::*;

    // This is the address of a running node.
    let server_address = "127.0.0.1:4000";

    // Create the provider using the client.
    let provider = Provider::connect(server_address).await.unwrap();

    // Create the wallet.
    let _wallet = WalletUnlocked::new_random(Some(provider));
}

Gets all coins owned by address from, with asset ID asset_id, even spent ones. This returns actual coins (UTXOs).

Get some spendable coins of asset asset_id for address from that add up at least to amount amount. The returned coins (UTXOs) are actual coins that can be spent. The number of coins (UXTOs) is optimized to prevent dust accumulation.

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.

Get the balance of all spendable coins asset_id for contract with id contract_id.

Get all the spendable balances of all assets for address address. This is different from getting the coins because we are only returning the numbers (the sum of UTXOs coins amount for each asset id) and not the UTXOs coins themselves

Get all balances of all assets for the contract with id contract_id.

Get block by id.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more