Thanks to visit codestin.com
Credit goes to aave.com

Chains

Learn how to discover supported blockchain networks in Aave v4.


Chain Structure

Chain data provides information about blockchain networks supported by Aave v4, including:

  • Identification: name, chain ID, icon URL

  • Configuration: explorer URL, whether it is a testnet

  • Native token details: wrapped token address and metadata

The following TypeScript interface illustrates the core Chain type:

interface Chain {  __typename: "Chain";  chainId: ChainId;  name: string;  icon: string;  rpcUrl: string;  explorerUrl: string;  isTestnet: boolean;  nativeWrappedToken: EvmAddress;  nativeInfo: TokenInfo;  nativeGateway: EvmAddress;  signatureGateway: EvmAddress;}

Listing Supported Chains

Discover all blockchain networks supported by Aave v4.

Use the useChains hook to fetch a list of supported chains.

import { type ChainsFilter, useChains } from "@aave/react";
function ChainsList({ filter }: { filter: ChainsFilter }) {  const { data, loading, error } = useChains({ filter });
  if (loading) return <div>Loading…</div>;
  if (error) return <div>Error: {error.message}</div>;
  return (    <div>      {data.map((chain) => (        <div key={chain.chainId}>          <h3>{chain.name}</h3>          <p>Chain ID: {chain.chainId}</p>        </div>      ))}    </div>  );}

Where ChainsFilter is one of:

  • ChainsFilter.ALL - All chains

  • ChainsFilter.MAINNET_ONLY - Mainnets only

  • ChainsFilter.TESTNET_ONLY - Testnets only

Fetching a Single Chain

Get detailed information about a specific blockchain network by its chain ID.

Use the useChain hook to fetch a specific chain.

import { type ChainRequest, useChain } from "@aave/react";
function ChainDetails({ request }: { request: ChainRequest }) {  const { data, loading, error } = useChain(request);
  if (loading) return <div>Loading…</div>;
  if (error) return <div>Error: {error.message}</div>;
  if (!data) return <div>Chain not found</div>;
  return (    <div>      <h3>{data.name}</h3>      <p>Chain ID: {data.chainId}</p>    </div>  );}

See below for an example of how to use the useChain hook.

Example
import { chainId } from "@aave/react";
const { data, loading, error } = useChain({  chainId: chainId(1),});