Function createNexusSessionClient

  • Creates a Nexus Client for interacting with the Nexus smart account system.

    Parameters

    • parameters: {
          account?: `0x${string}` | object & Assign_<SmartAccountImplementation<Abi, EntryPointVersion, object>, {
              address: `0x${string}`;
              getNonce: ((parameters?) => Promise<bigint>);
              isDeployed: (() => Promise<boolean>);
              type: "smart";
          }> & {
              address: `0x${string}`;
              getNonce: ((parameters?) => Promise<bigint>);
              isDeployed: (() => Promise<boolean>);
              type: "smart";
          } | Account;
          accountAddress?: `0x${string}`;
          attesterThreshold?: number;
          attesters?: `0x${string}`[];
          bootStrapAddress?: `0x${string}`;
          bundlerTransport: Transport;
          cacheTime?: number;
          chain?: Chain;
          client?: Client;
          factoryAddress?: `0x${string}`;
          index?: bigint;
          key?: string;
          module?: Assign_<BaseModule, undefined | object> & object;
          name?: string;
          paymaster?: true | {
              getPaymasterData?: ((parameters) => Promise<GetPaymasterDataReturnType>);
              getPaymasterStubData?: ((parameters) => Promise<GetPaymasterStubDataReturnType>);
          };
          paymasterContext?: PaymasterContext;
          pollingInterval?: number;
          registryAddress?: `0x${string}`;
          rpcSchema?: undefined;
          signer: OneOf<{
              address: `0x${string}`;
              experimental_signAuthorization?: ((parameters) => Promise<SignAuthorizationReturnType>);
              nonceManager?: NonceManager;
              publicKey: `0x${string}`;
              sign?: ((parameters) => Promise<`0x${string}`>);
              signMessage: ((__namedParameters) => Promise<`0x${string}`>);
              signTransaction: (<serializer, transaction>(transaction, options?) => Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, `0x${string}`> extends true
                  ? TransactionSerialized<GetTransactionType<transaction>>
                  : `0x${string}`>);
              signTypedData: (<const typedData, primaryType>(parameters) => Promise<`0x${string}`>);
              source: string;
              type: "local";
          } | EthersWallet | EthereumProvider | {
              account: Account;
              addChain: ((args) => Promise<void>);
              batch?: {
                  multicall?: boolean | {
                      batchSize?: number;
                      wait?: number;
                  };
              };
              cacheTime: number;
              ccipRead?: false | {
                  request?: ((parameters) => Promise<`0x${string}`>);
              };
              chain: undefined | Chain;
              deployContract: (<const abi, chainOverride>(args) => Promise<`0x${string}`>);
              extend: (<const client>(fn) => Client<Transport, undefined | Chain, Account, WalletRpcSchema, {
                  [K in string | number | symbol]: client[K]
              } & WalletActions<undefined | Chain, Account>>);
              getAddresses: (() => Promise<GetAddressesReturnType>);
              getChainId: (() => Promise<number>);
              getPermissions: (() => Promise<GetPermissionsReturnType>);
              key: string;
              name: string;
              pollingInterval: number;
              prepareTransactionRequest: (<const request, chainOverride, accountOverride>(args) => Promise<{
                  [K in string | number | symbol]: (UnionRequiredBy<(...) & (...), ParameterTypeToParameters<(...)>> & (unknown extends (...)[(...)]
                      ? {}
                      : Pick<(...), (...)>))[K]
              }>);
              request: EIP1193RequestFn<WalletRpcSchema>;
              requestAddresses: (() => Promise<RequestAddressesReturnType>);
              requestPermissions: ((args) => Promise<RequestPermissionsReturnType>);
              sendRawTransaction: ((args) => Promise<`0x${string}`>);
              sendTransaction: (<const request, chainOverride>(args) => Promise<`0x${string}`>);
              signMessage: ((args) => Promise<`0x${string}`>);
              signTransaction: (<chainOverride>(args) => Promise<`0x02${string}` | `0x01${string}` | `0x03${string}` | `0x04${string}` | TransactionSerializedLegacy>);
              signTypedData: (<const typedData, primaryType>(args) => Promise<`0x${string}`>);
              switchChain: ((args) => Promise<void>);
              transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
              type: string;
              uid: string;
              watchAsset: ((args) => Promise<boolean>);
              writeContract: (<const abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>);
          }>;
          transport: Transport;
          useTestBundler?: boolean;
          userOperation?: {
              estimateFeesPerGas?: ((parameters) => Promise<FeeValuesEIP1559>);
          };
          validatorAddress?: `0x${string}`;
      }
      • Optional account?: `0x${string}` | object & Assign_<SmartAccountImplementation<Abi, EntryPointVersion, object>, {
            address: `0x${string}`;
            getNonce: ((parameters?) => Promise<bigint>);
            isDeployed: (() => Promise<boolean>);
            type: "smart";
        }> & {
            address: `0x${string}`;
            getNonce: ((parameters?) => Promise<bigint>);
            isDeployed: (() => Promise<boolean>);
            type: "smart";
        } | Account

        The Account to use for the Client. This will be used for Actions that require an account as an argument.

      • Optional accountAddress?: `0x${string}`

        Account address

      • Optional attesterThreshold?: number

        Threshold

      • Optional attesters?: `0x${string}`[]

        Attesters

      • Optional bootStrapAddress?: `0x${string}`

        Boot strap address

      • bundlerTransport: Transport

        Bundler URL.

      • Optional cacheTime?: number

        Time (in ms) that cached data will remain in memory.

        Default

        4_000
        
      • Optional chain?: Chain

        Chain for the client.

      • Optional client?: Client

        Client that points to an Execution RPC URL.

      • Optional factoryAddress?: `0x${string}`

        Factory address of the account.

      • Optional index?: bigint

        Index of the account.

      • Optional key?: string

        A key for the client.

      • Optional module?: Assign_<BaseModule, undefined | object> & object

        Active module of the account.

      • Optional name?: string

        A name for the client.

      • Optional paymaster?: true | {
            getPaymasterData?: ((parameters) => Promise<GetPaymasterDataReturnType>);
            getPaymasterStubData?: ((parameters) => Promise<GetPaymasterStubDataReturnType>);
        }

        Paymaster configuration.

      • Optional paymasterContext?: PaymasterContext

        Paymaster context to pass to getPaymasterData and getPaymasterStubData calls.

      • Optional pollingInterval?: number

        Frequency (in ms) for polling enabled actions & events.

        Default

        4_000
        
      • Optional registryAddress?: `0x${string}`

        Registry address

      • Optional rpcSchema?: undefined

        Typed JSON-RPC schema for the client.

      • signer: OneOf<{
            address: `0x${string}`;
            experimental_signAuthorization?: ((parameters) => Promise<SignAuthorizationReturnType>);
            nonceManager?: NonceManager;
            publicKey: `0x${string}`;
            sign?: ((parameters) => Promise<`0x${string}`>);
            signMessage: ((__namedParameters) => Promise<`0x${string}`>);
            signTransaction: (<serializer, transaction>(transaction, options?) => Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, `0x${string}`> extends true
                ? TransactionSerialized<GetTransactionType<transaction>>
                : `0x${string}`>);
            signTypedData: (<const typedData, primaryType>(parameters) => Promise<`0x${string}`>);
            source: string;
            type: "local";
        } | EthersWallet | EthereumProvider | {
            account: Account;
            addChain: ((args) => Promise<void>);
            batch?: {
                multicall?: boolean | {
                    batchSize?: number;
                    wait?: number;
                };
            };
            cacheTime: number;
            ccipRead?: false | {
                request?: ((parameters) => Promise<`0x${string}`>);
            };
            chain: undefined | Chain;
            deployContract: (<const abi, chainOverride>(args) => Promise<`0x${string}`>);
            extend: (<const client>(fn) => Client<Transport, undefined | Chain, Account, WalletRpcSchema, {
                [K in string | number | symbol]: client[K]
            } & WalletActions<undefined | Chain, Account>>);
            getAddresses: (() => Promise<GetAddressesReturnType>);
            getChainId: (() => Promise<number>);
            getPermissions: (() => Promise<GetPermissionsReturnType>);
            key: string;
            name: string;
            pollingInterval: number;
            prepareTransactionRequest: (<const request, chainOverride, accountOverride>(args) => Promise<{
                [K in string | number | symbol]: (UnionRequiredBy<(...) & (...), ParameterTypeToParameters<(...)>> & (unknown extends (...)[(...)]
                    ? {}
                    : Pick<(...), (...)>))[K]
            }>);
            request: EIP1193RequestFn<WalletRpcSchema>;
            requestAddresses: (() => Promise<RequestAddressesReturnType>);
            requestPermissions: ((args) => Promise<RequestPermissionsReturnType>);
            sendRawTransaction: ((args) => Promise<`0x${string}`>);
            sendTransaction: (<const request, chainOverride>(args) => Promise<`0x${string}`>);
            signMessage: ((args) => Promise<`0x${string}`>);
            signTransaction: (<chainOverride>(args) => Promise<`0x02${string}` | `0x01${string}` | `0x03${string}` | `0x04${string}` | TransactionSerializedLegacy>);
            signTypedData: (<const typedData, primaryType>(args) => Promise<`0x${string}`>);
            switchChain: ((args) => Promise<void>);
            transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
            type: string;
            uid: string;
            watchAsset: ((args) => Promise<boolean>);
            writeContract: (<const abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>);
        }>

        Owner of the account.

      • transport: Transport

        RPC URL.

      • Optional useTestBundler?: boolean

        Use test bundler

      • Optional userOperation?: {
            estimateFeesPerGas?: ((parameters) => Promise<FeeValuesEIP1559>);
        }

        User Operation configuration.

        • Optional estimateFeesPerGas?: ((parameters) => Promise<FeeValuesEIP1559>)

          Prepares fee properties for the User Operation request.

            • (parameters): Promise<FeeValuesEIP1559>
            • Parameters

              • parameters: {
                    account: undefined | object & Assign_<SmartAccountImplementation<Abi, EntryPointVersion, object>, {
                        address: `0x${(...)}`;
                        getNonce: ((parameters?) => ...);
                        isDeployed: (() => ...);
                        type: "smart";
                    }> & {
                        address: `0x${string}`;
                        getNonce: ((parameters?) => Promise<(...)>);
                        isDeployed: (() => Promise<(...)>);
                        type: "smart";
                    };
                    bundlerClient: Client;
                    userOperation: UserOperationRequest;
                }
                • account: undefined | object & Assign_<SmartAccountImplementation<Abi, EntryPointVersion, object>, {
                      address: `0x${(...)}`;
                      getNonce: ((parameters?) => ...);
                      isDeployed: (() => ...);
                      type: "smart";
                  }> & {
                      address: `0x${string}`;
                      getNonce: ((parameters?) => Promise<(...)>);
                      isDeployed: (() => Promise<(...)>);
                      type: "smart";
                  }
                • bundlerClient: Client
                • userOperation: UserOperationRequest

              Returns Promise<FeeValuesEIP1559>

      • Optional validatorAddress?: `0x${string}`

        Owner module

    Returns Promise<NexusClient>

    Nexus Client. NexusClient

    Example

    import { createSmartAccountClient } from '@biconomy/sdk'
    import { http } from 'viem'
    import { mainnet } from 'viem/chains'

    const nexusClient = await createSmartAccountClient({
    chain: mainnet,
    transport: http('https://mainnet.infura.io/v3/YOUR-PROJECT-ID'),
    bundlerTransport: http('https://api.biconomy.io'),
    signer: '0x...',
    })