A Wallet Connector is an interface to integrate with third-party wallets on the Fuel Ecosystem. It exposes all currently installed wallets in a unified manner
via window.fuel
.
To list all available connectors you can use the listConnectors()
method.
const connectors = fuel.listConnectors();
To select a different Wallet Connector use the selectConnector(connectorName: string)
method.
async (connectorName: string) => {
console.log(`Select connector "${connectorName}"!`);
await fuel.selectConnector(connectorName);
console.log(`Connector "${connectorName}" connected`);
};
This event is triggered when the Current Connector is updated. The callback function receives the FuelWalletConnector
object.
fuel.on(fuel.events.currentConnector, onCurrentConnector);
return () => {
fuel.off(fuel.events.currentConnector, onCurrentConnector);
};
This event is triggered when the Connectors list is updated. The callback function receives the list of connectors, Array<FuelWalletConnector>
.
fuel.on(fuel.events.connectors, onConnectors);
return () => {
fuel.off(fuel.events.connectors, onConnectors);
};
Third-party wallets developed by the community can use the Wallet Connector to integrate with the current fuel
instance on the window, enabling a better experience for
developers and users.
Inside pageScript.ts
you can call the method createConnector
instead of creating a new object on the window. This method will add your Connector to the current,
window.fuel
element.
import { createConnector } from '@fuel-wallet/sdk';
createConnector({ name: 'Wallet Name' });
If you are using our Communication SDK Content Page Script import ContentProxyConnection
and pass the name of Wallet Extension.
Otherwise, remember to filter events by the ones that have your Wallet Connector Name as the target.
import { ContentProxyConnection } from '@fuel-wallet/sdk';
// Start the content page script with the current Wallet Name
ContentProxyConnection.start('Wallet Name');
// ...pageScript.ts logic for page script injection
Was this page helpful?