1.0.11 • Published 5 months ago

@cometh/connect-sdk-4337 v1.0.11

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Cometh Connect SDK

This SDK help any dApps to get a smoother UX for your end-users (control a wallet with biometrics, pay for his gas fees, social recovery...)

Installation

bun add viem @cometh/connect-sdk-4337

Setup

import { createComethPaymasterClient, createSafeSmartAccount, createSmartAccountClient } from "@cometh/connect-sdk-4337";
import { arbitrumSepolia } from "viem/chains";
import { http } from "viem";

const apiKey = process.env.NEXT_PUBLIC_COMETH_API_KEY;
const bundlerUrl = process.env.NEXT_PUBLIC_4337_BUNDLER_URL;

const smartAccount = await createSafeSmartAccount({
    apiKey,
    entryPoint: ENTRYPOINT_ADDRESS_V07 ,
})

const paymasterClient = await createComethPaymasterClient({
    transport: http(paymasterUrl),
    chain,
})

 const smartAccountClient = createSmartAccountClient({
    account: smartAccount,
    chain,
    bundlerTransport: http(bundlerUrl),
    paymaster: paymasterClient,
    userOperation: {
        estimateFeesPerGas: async () => {
            return await paymasterClient.getUserOperationGasPrice();
        },
    }
})

Send transaction

import { smartAccountClient } from "./client";
import countContractAbi from "../contract/counterABI.json";

const calldata = encodeFunctionData({
    abi: countContractAbi,
    functionName: "count",
});
  
const txHash =  await smartAccount.sendTransaction({
    to: COUNTER_CONTRACT_ADDRESS,
    data: calldata,
});

Send batch transactions

import { smartAccountClient } from "./client";
import countContractAbi from "../contract/counterABI.json";

const calldata = encodeFunctionData({
    abi: countContractAbi,
    functionName: "count",
});
  
const txHash =  await smartAccount.sendTransactions({
    calls: [
        {
        to: COUNTER_CONTRACT_ADDRESS,
        data: calldata,
        },
        {
        to: COUNTER_CONTRACT_ADDRESS,
        data: calldata,
        },
    ],
});

Handle owners

import { smartAccountClient } from "./client";

// get owners
const owners = await smartAccountClient.getOwners()

// get enriched owners (with passkey credentials)
const enrichedOwners = await smartAccountClient.getEnrichedOwners()

// add a new owner
await smartAccountClient.addOwner({ownerToAdd:OWNER_ADDRESS_TO_ADD})

// remove an owner
await smartAccountClient.removeOwner({ownerToRemove:OWNER_ADDRESS_TO_REMOVE})
1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

0.1.12

12 months ago

0.1.13

12 months ago

0.1.14

11 months ago

0.1.15

11 months ago

1.0.9

6 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.0-alpha.1

9 months ago

1.0.11-dev.1

5 months ago

1.0.11-dev.2

5 months ago

1.0.9-dev.1

6 months ago

1.0.6-dev.1

8 months ago

1.0.11-dev.3

5 months ago

0.3.0-alpha.2

9 months ago

1.0.11-dev.4

5 months ago

1.0.11-dev.5

5 months ago

1.0.11-dev.6

5 months ago

0.3.0-alpha.1

10 months ago

1.0.2-dev.1

9 months ago

1.0.11-rc.1

5 months ago

0.1.20

11 months ago

0.1.21

11 months ago

0.1.22

11 months ago

0.1.1-3.dev-2

12 months ago

0.1.1-3.dev-1

12 months ago

0.1.14-dev.1

11 months ago

0.3.0-dev.1

10 months ago

0.2.1

10 months ago

0.2.0

11 months ago

1.0.11

5 months ago

0.1.16

11 months ago

1.0.10

5 months ago

0.2.6

9 months ago

0.1.17

11 months ago

0.1.18

11 months ago

0.1.19

11 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.10-dev.2

1 year ago

0.1.10-dev.3

1 year ago

0.1.10-dev.1

1 year ago

0.1.9

1 year ago

0.1.6-dev.2

1 year ago

0.1.6-dev.1

1 year ago

0.1.6-dev.4

1 year ago

0.1.4-dev.2

1 year ago

0.1.6-dev.3

1 year ago

0.1.4-dev.1

1 year ago

0.1.7-dev.1

1 year ago

0.1.5-dev.1

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.0-rc.3

1 year ago

0.1.0-dev.13

1 year ago

0.1.1-dev.1

1 year ago

0.1.0-dev.12

1 year ago

0.1.1-dev.2

1 year ago

0.1.0-rc.1

1 year ago

0.1.0-dev.11

1 year ago

0.1.0-rc.2

1 year ago

0.1.0-dev.10

1 year ago

0.1.0-dev.14

1 year ago

0.1.2-dev.1

1 year ago

0.1.2-dev.2

1 year ago

0.1.0

1 year ago

0.1.0-dev.7

1 year ago

0.1.0-dev.8

1 year ago

0.1.1

1 year ago

0.1.0-dev.9

1 year ago

0.1.0-dev.6

1 year ago

0.1.0-dev.5

1 year ago

0.1.0-dev.4

1 year ago

0.1.0-dev.3

1 year ago

0.1.0-dev.2

1 year ago

0.1.0-dev.1

2 years ago