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

@0xgasless/0xgasless-aa-sdk

v0.0.26

Published

Account abstraction (ERC-4337) SDK layer

Downloads

192

Readme

0xgasless Account Abstraction SDK

Account abstraction (ERC-4337) SDK layer

Overview

This documentation provides an explanation of the AA0xGasless SDK functionalities used for interacting with smart contracts, focusing on account abstraction in accordance with the ERC-4337 standard. The SDK is designed to simplify the process of executing transactions in a gasless manner and interacting with EVM contracts.

Prerequisites

Before implementing the SDK, ensure the following requirements are met:

  • Node.js installed.
  • AA0xGasless SDK installed.

Environment Variables

Set up the following environment variable:

  • API_KEY: Your unique API key for the AA0xGasless SDK. Get the API key from 0xGasless dashboard.

SDK Initialization

  1. Initializing the SDK:
    const apiKey = process.env.API_KEY;
    const sdk = new AA0xGasless(apiKey);
    const smartAccountAddress = await sdk.init(provider, options);
    Initialize the AA0xGasless SDK with your API key. Replace provider and options with your specific configurations to set up the SDK properly.

options

The ClientOptions interface for the SDK configuration includes:

  • chainId (number): The chain ID of the Ethereum network.
  • privateKey (string, optional): The private key for signing transactions.
  • rpcUrl (string, optional): The URL of the Ethereum RPC endpoint.
  • isSponsoredTrx (boolean, optional): Indicates if the transaction is sponsored.
  • paymasterEndpoint (string, optional): The endpoint URL for the paymaster.
  • paymaster (string, optional): Type of paymaster, options are "PIMLICO" or "STACKUP".
  • bundlerEndpoint (string, optional): The endpoint URL for the bundler.

Configure these options as per your application's requirements.

Example: Simple Counter Contract Transaction

  1. Setting up Smart Contract Interaction:

    const apiKey = process.env.API_KEY;
    const sdk = new AA0xGasless(apiKey);
    const smartAccountAddress = await sdk.init(provider, options);
    const contractAddress = "<contract_address>";
    const abi = COUNTER_CONTRACT_ABI;
    const counterContract = new ethers.Contract(contractAddress, abi);

    Define the contract address and ABI of the ERC-721 contract for interaction using the SDK.

  2. Creating a Transaction:

    const trx = {
        target: contractAddress,
        data: counterContract.interface.encodeFunctionData("increment") `
    };

    Formulate a transaction object for invoking the increment function on the Counter contract through the SDK.

  3. Executing the Transaction:

    const userOpHash = await sdk.sendUserOp(trx);
    console.log("userOpHash", userOpHash);

    Send the transaction using the AA0xGasless SDK and get the operation hash and transaction hash.

Conclusion

This guide covers the basic setup and interaction with an simple Counter smart contract for incremeting using the AA0xGasless SDK. The SDK facilitates gasless transactions and simplifies the implementation of account abstraction as per ERC-4337.

Refer to the AA0xGasless SDK and ERC-4337 documentation for more detailed information.