Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@cometh/connect-core-sdk

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cometh/connect-core-sdk

SDK Cometh Connect Core

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
6
Created
Source

Cometh Connect SDK Lite

This Lite version of the Cometh Connect SDK 4337 provides the essential functions for managing smart accounts. It supports various authentication providers such as EOA, Magic, Web3Auth, Turnkey, and Privy, allowing developers to create and interact with smart accounts efficiently.

Installation

bun add viem @cometh/connect-core-sdk

Setup

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

const bundlerUrl = process.env.NEXT_PUBLIC_4337_BUNDLER_URL;
const paymasterUrl = process.env.NEXT_PUBLIC_4337_PAYMASTER_URL;

const signer = await providerToSmartAccountSigner(window.ethereum);

const publicClient = createPublicClient({
  chain: arbitrumSepolia,
  transport: http(),
  cacheTime: 60_000,
  batch: {
    multicall: { wait: 50 },
  },
});
const smartAccount = await createSafeSmartAccount({
  chain: arbitrumSepolia,
  publicClient,
  signer,
});

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

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 smartAccountClient.sendTransaction({
  to: COUNTER_CONTRACT_ADDRESS,
  data: calldata,
});

Keywords

cometh

FAQs

Package last updated on 22 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts