2.2.7 • Published 12 months ago

account-abstraction-wallet-sdk v2.2.7

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

Modular-Smart-Account-SDK

Introduction

a generic smart account SDK that can be used to interact with erc4337 smart account v3 and later. Developed with viem.sh to minimize the package

✅️one-click to create a modular smart account
✅️batch modular smart account creation
✅️only focus on the calldata logic, will do everything for you to set the gas price, nonce, etc.
✅local calculation instead of on chain querying

install dependencies

yarn

quick start

async function smoke_walletClient() {
  // this is a public client, it is necessary to have a public client to interact with the blockchain
  const publicClient: PublicClient = createPublicClient({
    chain: polygon,
    transport: http(),
    // "https://arb-mainnet.g.alchemy.com/v2/47SxM1HQgXWeKVL9rYVS6A4LZ8B_Ktk0",
  });

  // this is a signer, in this case, I use walletClient to act as a signer
  const walletClient: WalletClient = createWalletClient({
    account: privateKeyToAccount(process.env.WALLET_CLIENT_PRIVATE_KEY as Hex),
    chain: polygon,
    transport: http(),
    // "https://arb-mainnet.g.alchemy.com/v2/47SxM1HQgXWeKVL9rYVS6A4LZ8B_Ktk0",
  }).extend(publicActions);

  // now we create a instance which contains: a rpcProvider(publicClient), a signer(in this case, it is a walletClientSigner), the name and version of the smart account, and the index of it)
  const okxSmartContractAccount = await OKXSmartContractAccount.create({
    rpcProvider: publicClient,
    signer: new walletClientAASigner(walletClient),
    name: "SmartAccount",
    version: "3.0.2",
    index: 4n,

    // we need to config the bundlerClient and paymasterClient(optional unless you need a gas sponsor)
    bundlerClientConfig: {
      bundlerUrl: "https://beta.okex.org",
    },
    paymasterClientConfig: {
      paymasterUrl: "https://beta.okex.org",
    },
  });

  // act just like what you send transaction in ethers.js
  const hash = await okxSmartContractAccount.sendTransaction({
    to: zeroAddress,
    data: "0x",
    value: toHex(1),
    from: await okxSmartContractAccount.getAddress(),
  });

  // OR you can build a transaction and send it
  // const builtUop = await okxSmartContractAccount.buildUserOp({
  //   args: {
  //     to: zeroAddress,
  //     data: "0x",
  //     value: BigInt(1)
  //   },
  //   // you can specify what you want to override
  //   uopAndPaymasterOverrides: {
  //     preVerificationGas: BigInt(100000000),
  //     maxFeePerGas: BigInt(100000000000),
  //     maxPriorityFeePerGas: BigInt(100000000000),
  //     paymasterAddress: YOUR_PAYMASTER_ADDRESS
  //   }
  // })
  //
  // // then you can send this Uop
  // const sent = await okxSmartContractAccount.sendUserOp(builtUop);

  // wait for confirmation
  const res = await okxSmartContractAccount.bundlerClient.waitForConfirm(hash);
  console.log("successfully get the hash", res);
}
2.2.1

12 months ago

2.2.0

12 months ago

2.2.3

12 months ago

2.2.2

12 months ago

2.2.5

12 months ago

2.1.45

12 months ago

2.2.4

12 months ago

2.1.46

12 months ago

2.2.7

12 months ago

2.2.6

12 months ago

1.1.34

12 months ago

1.1.33

12 months ago

1.1.32

12 months ago

1.1.38

12 months ago

1.1.37

12 months ago

1.1.36

12 months ago

1.1.35

12 months ago

1.1.39

12 months ago

2.1.9

1 year ago

2.1.16

12 months ago

2.1.17

12 months ago

2.1.14

1 year ago

2.1.15

1 year ago

1.1.41

12 months ago

2.1.12

1 year ago

1.1.40

12 months ago

2.1.10

1 year ago

2.1.11

1 year ago

1.1.45

12 months ago

1.1.44

12 months ago

1.1.43

12 months ago

1.1.42

12 months ago

1.1.48

12 months ago

1.1.47

12 months ago

1.1.46

12 months ago

2.1.18

12 months ago

2.1.19

12 months ago

2.1.27

12 months ago

2.1.2

1 year ago

2.1.28

12 months ago

2.1.1

1 year ago

2.1.25

12 months ago

2.1.4

1 year ago

2.1.26

12 months ago

2.1.3

1 year ago

2.1.23

12 months ago

2.1.6

1 year ago

2.1.24

12 months ago

2.1.5

1 year ago

2.1.21

12 months ago

2.1.22

12 months ago

2.1.7

1 year ago

2.1.20

12 months ago

2.1.0

1 year ago

2.1.29

12 months ago

2.1.35

12 months ago

2.1.30

12 months ago

1.1.29

1 year ago

1.1.30

1 year ago

1.1.31

1 year ago

1.1.28

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

1.1.23

1 year ago

1.1.19

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.12

1 year ago

1.1.13

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago