Function getCustomChain

  • getCustomChain

    Utility method for creating a custom chain object

    Parameters

    • name: string

      The name of the chain

    • id: number

      The chainId (number)

    • rpcUrl: StringOrStrings

      The RPC URL for the chain - may also be an array of URLs

    • blockExplorer: StringOrStrings

      The block explorer URL for the chain - may also be an array of URLs

    • Optional nativeCurrency: ChainNativeCurrency

      The native currency for the chain, ETH by default

    • Optional contracts: {
          ensRegistry?: ChainContract;
          ensUniversalResolver?: ChainContract;
          multicall3?: ChainContract;
      }
      • Optional ensRegistry?: ChainContract
      • Optional ensUniversalResolver?: ChainContract
      • Optional multicall3?: ChainContract

    Returns Chain

    Example

    import { getCustomChain, createSmartAccountClient } from "@biconomy/account"

    const customChain = getCustomChain(
    "My Custom Chain",
    123456, // id
    "https://rpc.my-custom-chain.io", // Can also pass an array of URLs
    "https://explorer.my-custom-chain.io" // Can also pass an array of URLs
    )

    const account = privateKeyToAccount(`0x${privateKey}`)
    const walletClientWithCustomChain = createWalletClient({
    account,
    chain: customChain,
    transport: http()
    })

    const smartAccountCustomChain = await createSmartAccountClient({
    signer: walletClientWithCustomChain,
    bundlerUrl,
    customChain
    })

    const { wait } = await smartAccountCustomChain.sendTransaction({
    to: recipient,
    value: 1n
    })

    const { success, receipt } = await wait();
    console.log(success);