Skip to main content

Integration

Smart Accounts are created deterministically using the CREATE2 opcode, meaning the smart account address can be identified even before it is deployed. It will also maintain the same address across different chains. To integrate a AbstraXn Smart Account, you'll need the bundler url. If you also want to use the paymaster, you'll need Paymaster api key.

Installation​

First, install the following packages for initializing the Smart Account.

npm install @abstraxn/account

Integration

Specify PRIVATE_KEY, BUNDLER_URL, and RPC_URL (for ethers) to create a smart account.

import { Signer, ethers } from "ethers";
import { AbstraxnSmartAccount } from "@abstraxn/account";
import {
DEFAULT_ECDSA_OWNERSHIP_MODULE,
DEFAULT_ENTRYPOINT_ADDRESS,
ECDSAOwnershipValidationModule,
} from "@abstraxn/modules";
import { Bundler, IBundler } from "@abstraxn/bundler";
import { ChainId } from "@abstraxn/core-types";


const provider = new ethers.providers.Web3Provider(ethereum);


const bundler: IBundler = new Bundler({
bundlerUrl: "",
chainId: ChainId.SEPOLIA, // you can use multiple chains available in chainId object
entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS,
});

const ownerShipModule = await ECDSAOwnershipValidationModule.create({
signer: provider.getSigner() as Signer, // ethers signer object
moduleAddress: DEFAULT_ECDSA_OWNERSHIP_MODULE,
});

const abstraxnSmartAccount = await AbstraxnSmartAccount.create({
chainId: ChainId.SEPOLIA, // you can use multiple chains available in chainId object
activeValidationModule: ownerShipModule,
defaultValidationModule: ownerShipModule,
bundler: bundler, // instance of bundler
});

const address = await abstraxnSmartAccount.getAccountAddress();

In this doc, the following values are used by default:

  1. ECDSA Validation Module. Other validation modules can be enabled based on the specific use case.
  2. The default entry point address is used for the chainId.
  3. An index with a value 0, but you can also specify a custom index value in the configuration to generate multiple smart accounts with the same signer.
info

CREATE2 allows us to enable flows where users could even send funds to an undeployed wallet, which could then be used to pay for the gas for deployment. A smart account will be deployed with the first UserOp execution.