Docs Icon ChevronRight For Developers Icon ChevronRight API Reference

API Reference

Add ABI

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

Add Asset

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

Add Assets

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

Add Network

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

Clean

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

Connect

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

Current 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.

Current Connector

currentConnector(): FuelConnector
Return the current selected connector.

Current Network

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

Destroy

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

Disconnect

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

Events

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.

Usage

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.

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

Event 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>

Get ABI

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

Get Connection Status

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

Get Connector

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

Get Wallet

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

Has ABI

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

Has Connector

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

List Accounts

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

List Assets

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

List Connectors

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

List Networks

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

Request Signature Message

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

Select 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.

Select Network

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

Send Transaction

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

Unsubscribe All

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

Version

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