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

spacelisk-js

v0.0.2

Published

This library streamlines building ERC-4337 UserOperations and interacting with 4337 infrastructure on the lisk superchain.

Downloads

6

Readme

Spacelisk-js is a simple javascript library for interfacing with ERC-4337 Smart Account and Paymaster on the lisk chain. it uses spacelisk rpc enpoint by default.

Installation

npm i spacelisk-js

Usage

import { AA } from "spacelisk-js"

const pk = "0xprivate_key";
const api_key = "abcd1234";

const account = new AA(api_key, pk).account();

const address = await account.getAddress();
console.log("address:", address);

The address gotten is calculated by a default salt "0". if you want to generate more addresses you will simply need to set a salt. The account() function accepts an optional salt argument.

const account = new AA(api_key, pk).account("1"); // passed 1 as salt

Send user operation

Sending a user operation. This is a simple user operation that sends 0.001 ETH to 0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c. Here the user is responsibe for paying for transaction gas.

import { AA } from "spacelisk-js"

const pk = "0xprivate_key";
const api_key = "abcd1234";

const account = new AA(api_key, pk).account();

const data = await account.sendUserOp({
    to: "0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c",
    value: parseEther("0.001")
});

console.log("hash:", data.hash)

If you would like to use a paymaster, you can pass the paymaster address as a second argument to sendUserOp.

const data = await account.sendUserOp(
    {
     to: "0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c",
     value: parseEther("0.001")
    },
    "0x596c1E3dE33C91c16ee96C7C3Ab7146b99f84717" // Paymaster address
);

console.log("hash:", data.hash)

Send a user operation ( Smart Contract )

spacelisk-js ships with a helper function that builds a transaction by encoding the smart contract function data.

import { AA, encodeContractData } from "spacelisk-js"

const pk = "0xprivate_key";
const api_key = "abcd1234";

const account = new AA(api_key, pk).account();

const contractData = encodeContractData({
        address: "0x22441385da0f1c4bd08073b322303ae496fbb35c",
        functionName: "transfer",
        abi: ContractABI,
        args: [
                "0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c", 
                parseEther("0.001")
        ]
 })

const data = await account.sendUserOp(contractData);

console.log("hash:", data.hash)

If you would like to use a paymaster, you can pass the paymaster address as a second argument to sendUserOp.

const data = await account.sendUserOp(
    contractData,
    "0x596c1E3dE33C91c16ee96C7C3Ab7146b99f84717" // Paymaster address
);

console.log("hash:", data.hash)

UserOp Receipt

Easily fetch the user operation receipt (including the transaction receipt) with the below endpoint.

import { AA } from "spacelisk-js"

const pk = "0xprivate_key";
const api_key = "abcd1234";

const account = new AA(api_key, pk).account();

const receipt = await account.getReceipt(
 "0xc5dde62f72990ee1afdeef095d9d0c57e468410e81498ca10ceb58cb31c61d37" //hash
);
console.log("Receipt:", receipt);