⌘K

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);

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);

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);

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);

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();

Icon LinkCurrent Account

const { account } = useAccount();