Skip to content
Starknet Start

useWatchAsset

Request the user to add or watch an asset in their wallet.

Usage

import {  } from "@starknetfoundation/starknet-start-react";
 
const { ,  } = ({
  : {
    : "ERC20",
    : {
      : "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
      : "ETHER",
      : "ETH",
      : 18,
    },
  },
});

Arguments

params

  • Type: WatchAssetParameters

The asset definition. This type is defined in the Starknet Types package.

Returns

watchAsset

  • Type: (args?: WatchAssetParameters) => void

Function to send the request to the user, optionally overriding the arguments to the hook.

watchAssetAsync

  • Type: (args?: WatchAssetParameters) => Promise<boolean>

Send the request to the user and block until it receives a response.

data

  • Type: boolean | undefined

The resolved data.

error

  • Type: Error | null

Any error thrown by the mutation.

reset

  • Type: () => void

Reset the mutation status.

variables

  • Type: RequestArgs<"wallet_watchAsset"> | undefined

The request variables used by the underlying wallet mutation.

status

  • Type: "error" | "idle" | "pending" | "success"

The mutation status.

  • idle: the mutation has not been triggered yet.
  • pending: the mutation is being executed, e.g. waiting for the user to confirm in their wallet.
  • success: the mutation executed without an error.
  • error: the mutation threw an error.

isError

  • Type: boolean

Derived from status.

isIdle

  • Type: boolean

Derived from status.

isPending

  • Type: boolean

Derived from status.

isSuccess

  • Type: boolean

Derived from status.