Use the createAbstractClient function to initialize an AbstractClient instance, which provides a set of actions and methods to make use of the Abstract Global Wallet.

Import

import { createAbstractClient } from "@abstract-foundation/agw-client";
import type { AbstractClient } from "@abstract-foundation/agw-client"; // Optional

Usage

import { createAbstractClient } from "@abstract-foundation/agw-client";
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
import { abstractTestnet } from "viem/chains";

// As an example, we are creating a new dummy account here for the signer.
const randomPrivateKey = generatePrivateKey(); // Make a random private key
const account = privateKeyToAccount(randomPrivateKey); // Use that to create a signer

const agwClient = await createAbstractClient({
  chain: abstractTestnet,
  signer: account, // The "owner" (initial approved signer) of the AGW smart contract wallet.
});

const hash = await agwClient.sendTransaction({
  to: "0x273B3527BF5b607dE86F504fED49e1582dD2a1C6",
  data: "0x69",
});

console.log("Transaction sent:", `https://explorer.testnet.abs.xyz/tx/${hash}`);

Parameters

signer
Account
required

The EOA account that is the owner of the AGW smart contract wallet.

  • If this account has not yet created an Abstract Global Wallet, the first transaction they send will first deploy one, set the account as the owner and then continue with the transaction.

  • If the account has already created an Abstract Global Wallet, it will use the existing AGW.

address
ChainEIP712
required

A valid EIP712 chain such as abstractTestnet.

transport
ChainEIP712

A viem Transport. Defaults to http().

Returns

Returns an AbstractClient instance. This is an extension of the Viem wallet client with additional methods and properties specific to the Abstract Global Wallet.