1.0.0 • Published 1 year ago

safe-aa v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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";

// Create a new Web3Provider using the 'ethereum' object
const provider = new ethers.providers.Web3Provider(ethereum);

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

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

// Note that bundler is optional. You can choose to create new instances of this later and make account API use
const abstraxnSmartAccount = await AbstraxnSmartAccount.create({
    chainId: ChainId.POLYGON_MUMBAI, // you can use multiple chains available in chainId object
    activeValidationModule: ownerShipModule,
    defaultValidationModule: ownerShipModule,
    bundler: bundler, // instance of bundler
});

// you can get your smart account wallet address by getAccountAddress()
const address = await abstraxnSmartAccount.getAccountAddress();

//Contract instance
const contract = new ethers.Contract(
  contractAddress,
  Contract_ABI, // contract abi
  provider
);

//contract function 
const mint = await contract.populateTransaction.mint(
  //walletAddress,
  //amount
);

//transaction
const tx1 = {
  to: contractAddress,
  data: mint.data,
};

// you can create your userOp by buildUserOp()
const userOp = await abstraxnSmartAccount.buildUserOp([tx1, ...], {
    overrides: {
        ...
      }
});

// you can send your userOp to bundler by sendUserOp()
const userOpResponse = await abstraxnSmartAccount.sendUserOp(userOp);

//wait for response
const { receipt } = await userOpResponse.wait(1);

//your transaction receipt
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

1.0.0

1 year ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.20

1 year ago

0.0.65

1 year ago

0.0.21

1 year ago

0.0.66

1 year ago

0.0.22

1 year ago

0.0.67

1 year ago

0.0.23

1 year ago

0.0.68

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago