clawchain/wagmi/site/react/api/hooks/useWatchAsset.md

1.8 KiB

title, description
title description
useWatchAsset Hook for requesting user tracks the token in their wallet. Returns a boolean indicating if the token was successfully added.

useWatchAsset

Hook for requesting user tracks the token in their wallet. Returns a boolean indicating if the token was successfully added.

Import

import { useWatchAsset } from 'wagmi'

Usage

::: code-group

import { useWatchAsset } from 'wagmi'

function App() {
  const { watchAsset } = useWatchAsset()

  return (
    <button
      onClick={() => watchAsset({
        type: 'ERC20',
        options: {
          address: '0x0000000000000000000000000000000000000000',
          symbol: 'WAGMI',
          decimals: 18,
        },
      })}
    >
      Watch asset
    </button>
  )
}

<<< @/snippets/react/config.ts[config.ts] :::

Parameters

import { type UseWatchAssetParameters } from 'wagmi'

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

::: code-group

import { useWatchAsset } from 'wagmi'
import { config } from './config' // [!code focus]

function App() {
  const result = useWatchAsset({
    config, // [!code focus]
  })
}

<<< @/snippets/react/config.ts[config.ts] :::

Return Type

import { type UseWatchAssetReturnType } from 'wagmi'

Action