@biconomy/sdk
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
111 lines • 5.58 kB
TypeScript
import type { Account, Address, BundlerRpcSchema, Chain, Client, ClientConfig, EstimateFeesPerGasReturnType, LocalAccount, OneOf, Prettify, RpcSchema, Transport, WalletClient } from "viem";
import type { BundlerActions, BundlerClientConfig, PaymasterActions, SmartAccount, UserOperationRequest } from "viem/account-abstraction";
import { type ToNexusSmartAccountParameters } from "../account/toNexusAccount";
import type { EthersWallet } from "../account/utils/Utils";
import type { EthereumProvider } from "../account/utils/toSigner";
import type { AnyData, ModularSmartAccount, Module } from "../modules/utils/Types";
import type { PaymasterContext } from "./createBicoPaymasterClient";
import { type Erc7579Actions } from "./decorators/erc7579";
import { type SmartAccountActions } from "./decorators/smartAccount";
/**
* Nexus Client type
*/
export type NexusClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends ModularSmartAccount | undefined = ModularSmartAccount | undefined, client extends Client | undefined = Client | undefined, rpcSchema extends RpcSchema | undefined = undefined> = Prettify<Client<transport, chain extends Chain ? chain : client extends Client<AnyData, infer chain> ? chain : undefined, account, rpcSchema extends RpcSchema ? [...BundlerRpcSchema, ...rpcSchema] : BundlerRpcSchema, BundlerActions<account>>> & BundlerActions<ModularSmartAccount> & Erc7579Actions<ModularSmartAccount> & SmartAccountActions<chain, ModularSmartAccount> & {
/**
* The Nexus account associated with this client
*/
account: ModularSmartAccount;
/**
* Optional client for additional functionality
*/
client?: client | Client | undefined;
/**
* Transport configuration for the bundler
*/
bundlerTransport?: BundlerClientConfig["transport"];
/**
* Optional paymaster configuration
*/
paymaster?: BundlerClientConfig["paymaster"] | undefined;
/**
* Optional paymaster context
*/
paymasterContext?: PaymasterContext | undefined;
/**
* Optional user operation configuration
*/
userOperation?: BundlerClientConfig["userOperation"] | undefined;
};
/**
* Configuration for creating a Smart account Client
*/
export type SmartAccountClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, client extends Client | undefined = Client | undefined, rpcSchema extends RpcSchema | undefined = undefined> = Prettify<Pick<ClientConfig<transport, chain, SmartAccount, rpcSchema>, "account" | "cacheTime" | "chain" | "key" | "name" | "pollingInterval" | "rpcSchema"> & {
/** RPC URL. */
transport: transport;
/** Bundler URL. */
bundlerTransport: transport;
/** Client that points to an Execution RPC URL. */
client?: client | Client | undefined;
/** Paymaster configuration. */
paymaster?: true | {
/** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
getPaymasterData?: PaymasterActions["getPaymasterData"] | undefined;
/** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
getPaymasterStubData?: PaymasterActions["getPaymasterStubData"] | undefined;
} | undefined;
/** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
paymasterContext?: PaymasterContext;
/** User Operation configuration. */
userOperation?: {
/** Prepares fee properties for the User Operation request. */
estimateFeesPerGas?: ((parameters: {
account: SmartAccount | undefined;
bundlerClient: Client;
userOperation: UserOperationRequest;
}) => Promise<EstimateFeesPerGasReturnType<"eip1559">>) | undefined;
} | undefined;
/** Owner of the account. */
signer: OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount | EthersWallet>;
/** Index of the account. */
index?: bigint;
/** Active module of the account. */
module?: Module;
/** Factory address of the account. */
factoryAddress?: Address;
/** Owner module */
validatorAddress?: Address;
/** Account address */
accountAddress?: Address;
/** Attesters */
attesters?: ToNexusSmartAccountParameters["attesters"];
/** Threshold */
attesterThreshold?: ToNexusSmartAccountParameters["attesterThreshold"];
/** Boot strap address */
bootStrapAddress?: Address;
/** Registry address */
registryAddress?: Address;
/** Use test bundler */
useTestBundler?: boolean;
}>;
/**
* Creates a Nexus Client for interacting with the Nexus smart account system.
*
* @param parameters - {@link SmartAccountClientConfig}
* @returns Nexus Client. {@link 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...',
* })
*/
export declare function createSmartAccountClient(parameters: SmartAccountClientConfig): Promise<NexusClient>;
export declare const createNexusClient: typeof createSmartAccountClient;
export declare const createNexusSessionClient: typeof createSmartAccountClient;
//# sourceMappingURL=createSmartAccountClient.d.ts.map