⌘K

Icon HelpCircleForumIcon Link
Icon SunFilledIcon MoonStars

⌘K

Icon HelpCircleForumIcon Link
Icon SunFilledIcon MoonStars
Accounts

Icon LinkAccounts

Icon LinkList user accounts

Once the connection is authorized, you can list all the user accounts using accounts().

const accounts = await fuel.accounts();
console.log("Accounts", accounts);
Check if it's workingIcon AlertTriangleNot working

Icon LinkWatch Account Changes

To watch account events, you can use the accounts event.

function logAccounts(accounts: string) {
  console.log("Accounts ", accounts);
}
fuel.on(fuel.events.accounts, logAccounts);
Check if it's workingIcon AlertTriangleNot working

No accounts connected

Icon LinkGet Current Account

You can also get the current account being used in the wallet using currentAccount(). If the return is null this means that the current account selected by the user is not connected.

const currentAccount = await fuel.currentAccount();
console.log("Current Account", currentAccount);
Check if it's workingIcon AlertTriangleNot working

Icon LinkWatch Current Account Changes

To monitor events related to the current account, utilize the currentAccount event. Receiving a null value from this event indicates that the user's currently selected account is not connected. If the event receive a null value this means that the current account selected by the user is not connected.

function logCurrentAccount(account: string) {
  console.log("Current Account ", account);
}
fuel.on(fuel.events.currentAccount, logCurrentAccount);
Check if it's workingIcon AlertTriangleNot working

Icon LinkWith React

You can keep track of the current account when using React using the useAccount hook as shown below:

Icon LinkAll Connected Accounts

const { accounts } = useAccounts();
Check if it's workingIcon AlertTriangleNot working

No accounts connected

Icon LinkCurrent Account

const { account } = useAccount();
Check if it's workingIcon AlertTriangleNot working