# Use Account Abstraction

## What is Account Abstraction?

Account Abstraction is a blockchain technology that allows users to use smart contracts as their accounts, making them fully programmable.

It aims to make user accounts more flexible and functional, thus enhancing the user experience.

## What does it mean for Chiliz Chain developers?

By implementing AA, developers could enhance the user experience of their project: simpler Chiliz Chain interactions means a more user-friendly app.

## How to do it using Biconomy?

Biconomy provides a full-stack Account Abstraction SDK, which provides access to Smart Accounts: <https://docs.biconomy.io/account>

As per Biconomy themselves, there are 4 ways to leverage their AA stack on Chiliz Chain:

* Gasless Transactions&#x20;
* Batched Transactions&#x20;
* Smart contract wallets (including social login)&#x20;
* Modules including session keys, multichain validator, account recovery, and much more!

Biconomoy has a nice Quickstart page: <https://docs.biconomy.io/quickstart>

The sample code uses the Polygon Mumbai network, and you can adapt it to Chiliz, like so:

```typescript
import {
  Hex,
  createWalletClient,
  encodeFunctionData,
  http,
  parseAbi,
  zeroAddress,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { ChainId } from '@biconomy/core-types'
import { createSmartAccountClient } from "@biconomy/account";

const bundlerUrl =
  "https://bundler.biconomy.io/api/v2/80001/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44"; // Found at https://dashboard.biconomy.io

export const createAccountAndMintNft = async () => {
  // ----- 1. Generate EOA from private key
  const account = privateKeyToAccount("0x" + "PRIVATE_KEY");
  const client = createWalletClient({
    account,
    chainId: ChainId.CHILIZ_TESTNET, // or ChainId.CHILIZ_MAINNET,
    transport: http(),
  });
  const eoa = client.account.address;
  console.log(`EOA address: ${eoa}`);

  // ------ 2. Create biconomy smart account instance
  const smartAccount = await createSmartAccountClient({
    signer: client,
    bundlerUrl,
  });
  const saAddress = await smartAccount.getAccountAddress();
  console.log("SA Address", saAddress);
};
createAccountAndMintNft();
```

Remember the Chiliz Chain IDs:

* `CHILIZ_MAINNET = 88888`
* `CHILIZ_TESTNET = 88882`

Also, when working with Biconomy, note that Chiliz has [its own entrypoint address](https://docs.biconomy.io/contracts#entry-points), for both mainnet and testnet: [0x00000061FEfce24A79343c27127435286BB7A4E1](https://scan.chiliz.com/address/0x00000061FEfce24A79343c27127435286BB7A4E1/contracts#address-tabs)

This is important when using the Biconomy [Bundler](https://docs.biconomy.io/bundler) or [Paymaster](https://docs.biconomy.io/paymaster):

```typescript
// CC2 has its own entrypoint address
const CHILIZ_BUNDLER_ENTRYPOINT_ADDRESS='0x00000061FEfce24A79343c27127435286BB7A4E1'

const bundler = new Bundler({
    bundlerUrl: `https://bundler.biconomy.io/api/v2/${ChainId.CHILIZ_TESTNET}/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44`,
    chainId: ChainId.CHILIZ_TESTNET,
    entryPointAddress: CHILIZ_BUNDLER_ENTRYPOINT_ADDRESS,
})
```
