Function createWallet

    • Convenience function for creating environment-appropriate wallets

      This is a simplified wrapper around WalletFactory for quick wallet creation. It automatically detects the environment and creates the appropriate wallet type.

      When to use:

      • Quick prototyping and testing
      • Simple applications with one wallet instance
      • Default provider configuration is acceptable

      When to use WalletFactory instead:

      • Need to reuse the same provider for multiple wallets
      • Custom provider configuration required
      • Creating multiple wallet instances

      Parameters

      • Optionalconfig: WalletConfig

        Optional wallet configuration

        • privateKey

          Private key (required in Node.js, optional in browser)

        • pemContent

          PEM file content (alternative to privateKey)

        • pemPassword

          Password for encrypted PEM files

        • network

          Network to connect to

        • provider

          Custom provider instance

      Returns Promise<Wallet>

      Wallet instance appropriate for the current environment

      // Simple usage with defaults
      const wallet = await createWallet({
      privateKey: process.env.PRIVATE_KEY,
      })
      await wallet.connect()
      // Browser extension mode
      const wallet = await createWallet() // No config needed
      await wallet.connect() // Uses Klever Extension
      // Custom network
      const wallet = await createWallet({
      network: 'testnet',
      privateKey: process.env.TEST_PRIVATE_KEY,
      })