Icon LinkAssets

Icon LinkTransferring assets

To transfer an amount to other address, use the wallet.transfer method and pass in the address you want to send to and the amount to send.

const accounts = await fuel.accounts();
const account = accounts[0];
const wallet = await fuel.getWallet(account);
const toAddress = Address.fromString(addr);
const response = await wallet.transfer(toAddress, amount, assetId);
console.log("Transaction created!", response.id);

Icon LinkList Assets in the Wallet

You can list the assets in the wallet using window.fuel.assets().

const assets = await fuel.assets();
console.log("Assets ", assets);

Icon LinkAdding custom Assets

To add custom Assets, use the wallet.addAssets method and pass in the Asset[] you want to add.

await fuel.addAssets(assets);

Icon LinkListening to Asset Events

To listen to asset events, you can use the fuel.events.assets event.

const handleAssetsEvent = (assets: Asset[]) => {
  setAssets(assets);
};
 
useEffect(() => {
  fuel?.on(fuel.events.assets, handleAssetsEvent);
  return () => {
    fuel?.off(fuel.events.assets, handleAssetsEvent);
  };
}, [fuel]);