dAppBooster
    Preparing search index...
    • Token Input Hook

      Manages state and logic for token input components, handling:

      • Token amount and validation errors
      • Selected token state
      • Balance fetching for ERC20 and native tokens

      Parameters

      • Optionaltoken: {
            address: string;
            chainId: number;
            decimals: number;
            extensions?: Record<
                string,
                | undefined
                | null
                | string
                | number
                | bigint
                | boolean
                | Record<
                    string,
                    | undefined
                    | null
                    | string
                    | number
                    | bigint
                    | boolean
                    | Record<string, undefined | null | string | number | bigint | boolean>,
                >,
            >;
            logoURI?: string;
            name: string;
            symbol: string;
        }

        Optional initial token to select

      Returns {
          amount: bigint;
          amountError: undefined | null | string;
          balance: undefined | bigint;
          balanceError: null | Error;
          isLoadingBalance: boolean;
          selectedToken:
              | undefined
              | {
                  address: string;
                  chainId: number;
                  decimals: number;
                  extensions?: Record<
                      string,
                      | undefined
                      | null
                      | string
                      | number
                      | bigint
                      | boolean
                      | Record<
                          string,
                          | undefined
                          | null
                          | string
                          | number
                          | bigint
                          | boolean
                          | Record<string, undefined | null | string | number | bigint | boolean>,
                      >,
                  >;
                  logoURI?: string;
                  name: string;
                  symbol: string;
              };
          setAmount: Dispatch<SetStateAction<bigint>>;
          setAmountError: Dispatch<SetStateAction<undefined | null | string>>;
          setTokenSelected: Dispatch<
              SetStateAction<
                  | undefined
                  | {
                      address: string;
                      chainId: number;
                      decimals: number;
                      extensions?: Record<
                          string,
                          | undefined
                          | null
                          | string
                          | number
                          | bigint
                          | boolean
                          | Record<
                              string,
                              | undefined
                              | null
                              | string
                              | number
                              | bigint
                              | boolean
                              | Record<(...), (...)>,
                          >,
                      >;
                      logoURI?: string;
                      name: string;
                      symbol: string;
                  },
              >,
          >;
      }

      Hook return object

      const {
      amount,
      balance,
      selectedToken,
      setAmount,
      setTokenSelected
      } = useTokenInput(defaultToken);