Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Nightly /
Provider

Icon LinkProvider

The Provider Icon Link lets you connect to a Fuel node (local or external ) and interact with it, encapsulating common client operations in the SDK. Those operations include querying the blockchain for network, block, and transaction-related info (and more Icon Link), as well as sending transactions to the blockchain.

All higher-level abstractions (e.g. Wallet , Contract ) that interact with the blockchain go through the Provider, so it's used for various actions like getting a wallet's balance, deploying contracts, querying their state, etc.

import { Provider, WalletUnlocked } from 'fuels';
 
import { LOCAL_NETWORK_URL } from '../../../env';
 
// Create the provider
const provider = await Provider.create(LOCAL_NETWORK_URL);
 
// Querying the blockchain
const { consensusParameters } = provider.getChain();
 
// Create a new wallet
const wallet = WalletUnlocked.generate({ provider });
 
// Get the balances of the wallet (this will be empty until we have assets)
const { balances } = await wallet.getBalances();
// []

You can find more examples of Provider usage here .