1.0.26 • Published 8 months ago

thorn-aa-sdk v1.0.26

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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);
1.0.26

8 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.22

11 months ago

1.0.21

12 months ago

1.0.20

12 months ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.1-3.alpha

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago