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

thorn-aa-sdk

v1.0.26

Published

Thorn Account Abstraction SDK

Downloads

189

Readme

Thorn Account Abstraction SDK

This package is only for Thorn-protocol testnet

Installation

npm i thorn-aa-sdk

Quickstart

import { SmartAccountClient } from "thorn-aa-sdk";

const userSA = await SmartAccountClient.create(signer);

const result = await userSA.buildUserOpSignAndSend([tx]);

const { receipt, success } = result.wait();

Usages

Get Smart Account address

const address = await userSA.getAddress();

Check if user already has Account Abstraction

await userSA.isAccountDeployed();

Deploy Smart Account if it not deploy

in here, we need a third wallet to send a transaction to deploy wallet

await tx = await userSA.deploy();

this function return a UnsignedTransaction, need signed and send to create wallet

Get Balance tokens of Smart Account

const balances = userSA.getBalance(["0x6718660522aAa470eb6EbcC461d505f518686Dc5", "0x8ab7B0c47f07E19C86E35Ebb44453cB266d1E79c"]);
//result form :
/*
 [
  {
    address: '0x6718660522aAa470eb6EbcC461d505f518686Dc5',
    name: 'TST',
    symbol: 'MockToken',
    decimals: 6,
    balance: 0
  },
  {
    address: '0x8ab7B0c47f07E19C86E35Ebb44453cB266d1E79c',
    name: 'MockWrappedNative',
    symbol: 'wNATIVE',
    decimals: 18,
    balance: 0
  }
]
*/

Create transaction and send transaction

To send a transaction as a Smart Account, we need to build UnsignedTransactions corresponding to the execution commands, then use the sdk to interact, the sdk synthesizes the transactions into 1 UserOp, signs them and sends them to the bundler. to execute.

const erc20Interface = new Contract(addressContract, erc20Abi, provider);
const tx = await erc20Interface.getFunction("transfer").populateTransaction(addressInput, parseUnits(amountInput, 6));
const result = await userSA.buildUserOpSignAndSend([tx1, tx2, tx3]);
const { receipt, success } = await result.wait();

To create UnsignedTransactions, you can learn more about populateTransaction, the tx input needs at least 3 fields to, value, data.

Send transaction with token paymaster

If you want your transaction to be paid in Erc-20 coins instead of ROSE, add the parameter address token

const result = await userSA.buildUserOpSignAndSend([tx], tokenAddress);
const { receipt, success } = result.wait();

Paymaster

//Create object
import { UserTokenPaymaster } from "thorn-aa-sdk";
const paymaster = new UserTokenPaymaster();

// Get List token paymaster support
const listTokenSupport = await paymaster.getListTokenSupport();

// Get list token user approved
const listTokenUserApproved = await paymaster.getListTokenUserApproved(address);