Abstraxn - Account
Facilitating the integration and deployment of Smart Accounts, as well as constructing and dispatching user operations, stands as a pivotal feature within any toolkit designed for ERC4337. This package seamlessly incorporates the fundamental attributes associated with ERC-4337, streamlining the development process for your Dapp's account and transaction rails while incorporating additional usability features.
The account package accomplishes this by offering a comprehensive set of methods, empowering developers to effortlessly generate UserOperations. Augmented by the sophisticated, developer-friendly, and scalable abstraction layer provided by Abstraxn, it ensures the efficient and reliable transmission of these operations across multiple EVM chains.
What is a Smart Account Wallet?
In ERC-4337, a smart account is a dedicated smart contract managing assets and generating userOps, pseudo-transaction objects executed on the EVM, replacing traditional Externally Owned Accounts.
Installation and Usage
The easiest way to use Abstraxn - Account is to install it from npm:
npm install @abstraxn/account
Install the required packages for initializing the Smart Account
npm install ethers@5.7 @abstraxn/account @abstraxn/bundler @abstraxn/common @abstraxn/core-types @abstraxn/modules
Example Usage
Create a Smart account wallet:
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.POLYGON_MUMBAI,
entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS,
});
const ownerShipModule = await ECDSAOwnershipValidationModule.create({
signer: provider.getSigner() as Signer,
moduleAddress: DEFAULT_ECDSA_OWNERSHIP_MODULE,
});
const abstraxnSmartAccount = await AbstraxnSmartAccount.create({
chainId: ChainId.POLYGON_MUMBAI,
activeValidationModule: ownerShipModule,
defaultValidationModule: ownerShipModule,
bundler: bundler,
});
const address = await abstraxnSmartAccount.getAccountAddress();
const contract = new ethers.Contract(
contractAddress,
Contract_ABI,
provider
);
const mint = await contract.populateTransaction.mint(
);
const tx1 = {
to: contractAddress,
data: mint.data,
};
const userOp = await abstraxnSmartAccount.buildUserOp([tx1, ...], {
overrides: {
...
}
});
const userOpResponse = await abstraxnSmartAccount.sendUserOp(userOp);
const { receipt } = await userOpResponse.wait(1);
console.log(receipt)
Main Functions
-
create()
- Used for setting the SDK API key on the frontend.
-
getAccountAddress()
- Deploys a multisig wallet for the user.
-
buildUserOp()
- Creates signatures for approvers for all transactions.
-
sendUserOp()
- Executes functions using the multisig wallet.
-
... and so on
License
This package is MIT licensed. (c) Antier Solutions 2024.
Authors