SDK Core

This Core 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.

The Core SDK does not require an API key. However, some advanced features, such as the Cometh Passkey signer, are not available in this version.

Install

npm i @cometh/connect-core-sdk viem

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();
        },
    }
})

SDK Core Features

Send a transaction

Send batch transactions

Sign a message

Encode contract calls

Specify contract addresses

By default, the SDK Core uses the following contract addresses:

If you want to specify custom contract addresses, you can pass the safeContractConfig parameter when creating a smart account:

Type of safeContractConfig:

Last updated