useAccount
Retrieves the current fuel account and returns the account address <string | undefined>
.
1const { account } = useAccount();
2console.log(account);
3// fuel1r20zhd...
useAccounts
Retrieves the fuel accounts and returns the addresses of the accounts <string[] | undefined>
1const { accounts } = useAccounts();
2console.log(accounts);
3// [fuel1r20zhd..., fuel1qqluc9..., ...]
useBalance
Fetches the balance <number | undefined>
of a specified address and asset ID. Additionally, it includes a listener that triggers a balance refresh when the window gains focus.
1const { balance } = useBalance({
2 address: 'fuel1r20zhd...',
3 assetId: '0x000000000...',
4});
5
6console.log(balance);
7// 1000 (example balance)
useChain
Fetches information about the current Fuel network <ChainInfo | undefined>
.
1const { chain } = useChain();
2console.log(chain.name);
useConnect
Facilitates the connection to the Fuel wallet. Allows selecting a connector by name. It also provides a function <UseMutateAsyncFunction<boolean | undefined>>
to initiate the connection and relevant mutation properties for managing the connection state.
1const { connect } = useConnect();
2
3const handleConnect = async () => {
4 await connect('exampleConnectorName');
5};
6
7handleConnect();
useConnectors
Retrieves a list of available connectors <Array<FuelWalletConnector>>
for connecting to Fuel.
1const { connector } = useConnectors();
2
3console.log(connectors);
useDisconnect
Facilitates disconnection from the Fuel Wallet. It provides a function <UseMutateAsyncFunction<boolean | undefined>>
to initiate disconnection.
1const { disconnect } = useDisconnect();
2
3const handleDisconnect = async () => {
4 await disconnect();
5};
6
7handleDisconnect();
useIsConnected
Checks whether the user is connected to the Fuel protocol. It provides a boolean
indicating the connection.
1const { isConnected } = useIsConnected();
2console.log(isConnected);
3// true
useNodeInfo
Asynchronously retrieves information about the connected node, checks compatibility with a specified version. The function returns isCompatible
(a <boolean>
), and node information.
1const { isCompatible } = useNodeInfo();
useProvider
Returns the provider from the Fuel object instance.
1const { provider } = useProvider();
useTransaction
Retrieves transaction information associated with a specific transaction ID by using the provider.getTransaction
method.
1const { transaction } = useTransaction({ txId: 'fuel1r20zhd...' });
useTransactionReceipts
Retrieves transaction receipts <TransactionResponse.Receipts>
associated with a specific transaction ID using the useFuel
hook.
1const { transactionReceipts } = useTransactionReceipts({
2 txId: 'fuel1r20zhd...',
3});
useWallet
Retrieves wallet instance <FuelWalletLocked | undefined>
and ensures the presence of a valid address and fuel instance.
1const { wallet } = useWallet({ address: 'fuel1r20zhd...' });