Function to create an instance of the Abstract Global Wallet client.
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.
This is useful if you need to create a new AbstractClient instance when you already have a signer, such as
in the server-side environment of your application.
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 keyconst account =privateKeyToAccount(randomPrivateKey);// Use that to create a signerconst agwClient =awaitcreateAbstractClient({ 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://sepolia.abscan.org/tx/${hash}`);
The EOA account that owns 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.
Returns an AbstractClient instance. This is an extension of the Viem wallet client with
additional methods and properties specific to the Abstract Global Wallet.