Metamask EOA

Metamask with EIP1993

EIP-1193 is a standard interface for Ethereum providers, such as MetaMask or hardware wallets, where the key material is hosted externally rather than on the local client.

import { ENTRYPOINT_ADDRESS_V07, createSafeSmartAccount, 
createSmartAccountClient } from "@cometh/connect-sdk-4337";
import { http } from "viem"
import { providerToSmartAccountSigner } from "permissionless";

const apiKey = process.env.COMETH_API_KEY;
const bundlerUrl = process.env.4337_BUNDLER_URL;
const rpcUrl = process.env.RPC_URL;

const signer = await providerToSmartAccountSigner(
    window.ethereum
);

const smartAccount = await createSafeSmartAccount({
    apiKey,
    rpcUrl,
    chain: arbitrumSepolia,
    entryPoint: ENTRYPOINT_ADDRESS_V07,
    signer
 });
 
const walletAddress = smartAccount.address
        
const smartAccountClient = createSmartAccountClient({
    account: smartAccount,
    entryPoint: ENTRYPOINT_ADDRESS_V07,
    chain: arbitrumSepolia,
    bundlerTransport: http(bundlerUrl)
})
  

Metamask with Viem integration

A Wallet Client is an interface to interact with Ethereum Account(s) and provides the ability to retrieve accounts, execute transactions, sign messages, etc through Wallet Actions.

import { ENTRYPOINT_ADDRESS_V07, createSafeSmartAccount, 
createSmartAccountClient } from "@cometh/connect-sdk-4337";
import { http } from "viem"
import { walletClientToSmartAccountSigner } from "permissionless";

const apiKey = process.env.COMETH_API_KEY;
const bundlerUrl = process.env.4337_BUNDLER_URL;
const rpcUrl = process.env.RPC_URL;

const signer = walletClientToSmartAccountSigner(walletClient);

const smartAccount = await createSafeSmartAccount({
    apiKey,
    rpcUrl,
    chain: arbitrumSepolia,
    entryPoint: ENTRYPOINT_ADDRESS_V07,
    signer
 });
 
const walletAddress = smartAccount.address
        
const smartAccountClient = createSmartAccountClient({
    account: smartAccount,
    entryPoint: ENTRYPOINT_ADDRESS_V07,
    chain: arbitrumSepolia,
    bundlerTransport: http(bundlerUrl)
})
  

Last updated