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,
                | string
                | number
                | bigint
                | boolean
                | Record<
                    string,
                    | string
                    | number
                    | bigint
                    | boolean
                    | Record<string, string | number | bigint | boolean | null | undefined>
                    | null
                    | undefined,
                >
                | null
                | undefined,
            >;
            logoURI?: string;
            name: string;
            symbol: string;
        }

        Optional initial token to select

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

      Hook return object

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