The getLinkedAgw function is available when extending a Viem Client with linkableWalletActions. It can be used to check if an Ethereum Mainnet address has linked an Abstract Global Wallet.

Usage

import { linkableWalletActions } from "@abstract-foundation/agw-client";
import { createWalletClient, custom } from "viem";
import { sepolia } from "viem/chains";

export default function CheckLinkedWallet() {
  async function checkLinkedWallet() {
    // Initialize a Viem Wallet client: (https://viem.sh/docs/clients/wallet)
    // And extend it with linkableWalletActions
    const client = createWalletClient({
      chain: sepolia,
      transport: custom(window.ethereum!),
    }).extend(linkableWalletActions());

    // Check if an address has a linked AGW
    const { agw } = await client.getLinkedAgw();

    if (agw) {
      console.log("Linked AGW:", agw);
    } else {
      console.log("No linked AGW found");
    }
  }

  return <button onClick={checkLinkedWallet}>Check Linked AGW</button>;
}

Parameters

address
Address

The Ethereum Mainnet address to check for a linked AGW. If not provided, defaults to the connected account’s address.

Returns

agw
Address | undefined

The address of the linked Abstract Global Wallet, or undefined if no AGW is linked.