SmartWallet.init constructor

SmartWallet.init(
  1. {required Chain chain,
  2. required MultiSignerInterface signer,
  3. required BundlerProviderBase bundler,
  4. RPCProviderBase? jsonRpcProvider,
  5. EthereumAddress? address,
  6. String? initCode}
)

Initializes the SmartWallet instance and the associated Entrypoint contract.

Use this method directly when you need to interact with the entrypoint, wait for user Operation Events, or recovering an account.

  • chain: The blockchain chain.
  • signer: required multi-signer interface
  • bundler: The bundler provider.
  • jsonRpcProvider: The Ethereum JSON RPC provider (optional).
  • address: The Ethereum address (optional).
  • initCode: The init code (optional).

Implementation

factory SmartWallet.init(
    {required Chain chain,
    required MultiSignerInterface signer,
    required BundlerProviderBase bundler,
    RPCProviderBase? jsonRpcProvider,
    EthereumAddress? address,
    String? initCode}) {
  final instance = SmartWallet(
      chain: chain,
      signer: signer,
      bundler: bundler,
      jsonRpcProvider: jsonRpcProvider,
      address: address);

  instance
    ..dangerouslySetInitCode(initCode)
    ..plugin<BundlerProviderBase>('bundler')
        .initializeWithEntrypoint(Entrypoint(
      address: chain.entrypoint,
      client: instance.plugin<_AccountFactory>('factory').client,
    ));

  return instance;
}