addAbi(abiMap: AbiMap): Promise<boolean>
Add the ABI to the user's wallet.
addAsset(asset: Asset): Promise<boolean>
Request the user to add metadata for an asset to the wallet.
addAssets(asset: Asset[]): Promise<boolean>
Request the user to add metadata for multiple assets to the wallet at once.
addNetwork(url: string): Promise<boolean>
Request the user to add a new network. Return true if success or false it fails.
clean(): void
Clean the storage used by the Fuel SDK, which is utilized to keep track of the selected connector.
connect(): Promise<boolean>
Request permission to start a connection between the project and the wallet. Return the connection state.
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.
currentConnector(): FuelConnector
Return the current selected connector.
currentNetwork(): Promise<Network>
Return the current network being used in the wallet application.
destroy(): void
Removes all listeners and cleans the storage.
disconnect(): Promise<boolean>
Disconnect your project from the wallet. Return the connection state.
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 FuelConnectorEventTypes
can be imported from the @fuels
package.
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 | 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> |
getABI(contractId: string): Promise<JsonAbi>
Return the ABI of the given contractId, or null if not found.
isConnected(): Promise<boolean>
Return the state of the application connection.
getConnector(connectorName: string): FuelConnector
Return the connector with the given name.
getWallet(address: string | AbstractAddress, provider?: Provider): Promise<Account>
Return a Account
instance, which can be used for contracts, transfers, and other interactions.
hasABI(contractId: string): Promise<boolean>
Return a boolean indicating if the ABI for the given contractId is found.
hasConnector(connectorName?: string | FuelConnector): Promise<boolean>
Check if any connector is present or, if a connector is provided, check whether it is available.
accounts(): Promise<Array<string>>
Return the accounts authorized for the current connection.
assets(): Promise<Array<Asset>>
Return the list of assets in the current wallet.
connectors(): Promise<Array<FuelConnector>>
Return connectors with availability metadata.
networks(): Promise<Array<Network>>
Return the list of networks in the current wallet.
async signMessage(address: string, message: string): Promise<string>
Request a message signature for one specific account.
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.
selectNetwork(url: string): Promise<boolean>
Request the user to switch to a different network. Return true if success or false it fails.
async sendTransaction(address: string, transaction: TransactionRequestLike): Promise<string>
Request a specific user account to send a transaction.
unsubscribe(): void
Remove all open listeners. This is useful when you want to dispose of the Fuel instance and avoid memory leaks.
version(): Promise<string>
Return the current version of the Wallet and Network supported.