npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

safe-aa

v1.0.1

Published

safe-aa: Empower ERC-4337 smart accounts with seamless APIs for enhanced decentralized finance experiences.

Downloads

201

Readme

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 [email protected] @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