⌘K

Icon SunFilledIcon MoonStars
API Reference

Icon LinkAPI Reference

Icon LinkAdd ABI

addAbi(abiMap: AbiMap): Promise<boolean>
Add the ABI to the user's wallet.

Icon LinkAdd Asset

addAsset(asset: Asset): Promise<boolean>
Request the user to add metadata for an asset to the wallet.

Icon LinkAdd Assets

addAssets(asset: Asset[]): Promise<boolean>
Request the user to add metadata for multiple assets to the wallet at once.

Icon LinkAdd Network

addNetwork(url: string): Promise<boolean>
Request the user to add a new network. Return true if success or false it fails.

Icon LinkClean

clean(): void
Clean the storage used by the Fuel SDK, which is utilized to keep track of the selected connector.

Icon LinkConnect

connect(): Promise<boolean>
Request permission to start a connection between the project and the wallet. Return the connection state.

Icon LinkCurrent Account

currentAccount(): Promise<string | null>
Return the current account being used in the wallet application. If the account selected is not authorized for the connection, returns null.

Icon LinkCurrent Connector

currentConnector(): FuelConnector
Return the current selected connector.

Icon LinkCurrent Network

currentNetwork(): Promise<Network>
Return the current network being used in the wallet application.

Icon LinkDestroy

destroy(): void
Removes all listeners and cleans the storage.

Icon LinkDisconnect

disconnect(): Promise<boolean>
Disconnect your project from the wallet. Return the connection state.

Icon LinkEvents

Fuel emits events when certain actions occur. These events can be listened to by using the on method.

The events API follows the native Node.js EventEmitter enabling, on, once, and off. The events enum FuelWalletEvents can be imported from the @fuel-wallet/sdk package.

Icon LinkUsage

The fuel object has an events property which is an enum of all the events that can be listened to.
The on method takes two arguments, the event name and a callback function. The callback function receives data associated with the event.

fuel.on(fuel.events.connection, (connectionState) => {
	console.log(connectionState);
});

Icon LinkEvent Types

Event
Trigger
Params
connectors
connectors change
Array<FuelConnector>
currentConnector
current connector change
FuelConnector
accounts
accounts available change
Array<string>
currentAccount
current account change
string | null
connection
connection state change
boolean
currentNetwork
current network change
Network
assets
assets metadata change
Array<Asset>

Icon LinkGet ABI

getABI(contractId: string): Promise<JsonAbi>
Return the ABI of the given contractId, or null if not found.

Icon LinkGet Connection Status

isConnected(): Promise<boolean>
Return the state of the application connection.

Icon LinkGet Connector

getConnector(connectorName: string): FuelConnector
Return the connector with the given name.

Icon LinkGet Wallet

getWallet(address: string | AbstractAddress, provider?: FuelWalletProvider): Promise<FuelWalletLocked>
Return a FuelWalletLocked instance, which can be used for contracts, transfers, and other interactions.

Icon LinkHas ABI

hasABI(contractId: string): Promise<boolean>
Return a boolean indicating if the ABI for the given contractId is found.

Icon LinkHas Connector

hasConnector(connectorName?: string | FuelConnector): Promise<boolean>
Check if any connector is present or, if a connector is provided, check whether it is available.

Icon LinkList Accounts

accounts(): Promise<Array<string>>
Return the accounts authorized for the current connection.

Icon LinkList Assets

assets(): Promise<Array<Asset>>
Return the list of assets in the current wallet.

Icon LinkList Connectors

connectors(): Promise<Array<FuelConnector>>
Return connectors with availability metadata.

Icon LinkList Networks

networks(): Promise<Array<Network>>
Return the list of networks in the current wallet.

Icon LinkRequest Signature Message

async signMessage(address: string, message: string): Promise<string>
Request a message signature for one specific account.

Icon LinkSelect Connector

selectConnector(connectorName: string): Promise<boolean>
This method will check if the desired connector is installed. If it is not detected in 1 second, the method throws an error.

Icon LinkSelect Network

selectNetwork(url: string): Promise<boolean>
Request the user to switch to a different network. Return true if success or false it fails.

Icon LinkSend Transaction

async sendTransaction(address: string, transaction: TransactionRequestLike): Promise<string>
Request a specific user account to send a transaction.

Icon LinkUnsubscribe All

unsubscribe(): void
Remove all open listeners. This is useful when you want to dispose of the Fuel instance and avoid memory leaks.

Icon LinkVersion

version(): Promise<string>
Return the current version of the Wallet and Network supported.