create Wallet
Creates a new smart account wallet with WebAuthn passkey authentication.
Creates a new wallet by generating a WebAuthn credential, deriving the contract address, and optionally deploying the smart account contract to the network.
Flow:
Validate WebAuthn provider and autoFund requirements
Call WebAuthn registration (user authenticates with biometric/security key)
Extract and normalize secp256r1 public key from attestation
Derive deterministic contract address from credential ID
Save credential as pending in storage
Set connected state and save session (before deployment)
Build and sign the deploy transaction (always, regardless of autoSubmit)
If autoSubmit: submit the transaction, fund wallet if autoFund, delete credential
Return result
Auto-Fund Feature
When autoFund = true, the wallet is automatically funded after deployment using Friendbot (testnet only). This is useful for onboarding flows where users need immediate access to a funded wallet.
Requirements for autoFund:
autoSubmitmust be true (wallet must be deployed first)nativeTokenContractmust be provided (the native token contract address)Must be on testnet (Friendbot is testnet-only)
Relayer may be used for fee sponsoring if configured
IMPORTANT: Requires a WebAuthnProvider to be configured in the kit config. Throws WEBAUTHN_NOT_SUPPORTED if no provider is configured.
Return
CreateWalletResult containing credential ID, contract address, signed transaction XDR, and optional transaction hash
Parameters
Display name for the user (default: "Smart Account User")
Whether to automatically submit the deploy transaction (default: false)
Whether to automatically fund the wallet after deployment (default: false)
Contract address for the native token (required if autoFund is true)
Optional override to force relayer or RPC submission (default: auto-detect)
See also
for manual funding after deployment
for retrying a failed or deferred deployment
Throws
if WebAuthn registration fails or no provider configured
if public key extraction fails or nativeTokenContract is missing when autoFund is true
if deployment or funding fails
if credential storage fails
if storage write fails
Example:
// Create wallet without deploying — signedTransactionXdr always present for external submission
val wallet = walletOps.createWallet(userName = "Alice", autoSubmit = false)
println("Wallet address: ${wallet.contractId}")
println("Signed XDR: ${wallet.signedTransactionXdr}")
// Create and deploy immediately
val deployedWallet = walletOps.createWallet(userName = "Bob", autoSubmit = true)
println("Deployed at: ${deployedWallet.transactionHash ?: "unknown"}")
// Create, deploy, and fund with native token (testnet)
val fundedWallet = walletOps.createWallet(
userName = "Charlie",
autoSubmit = true,
autoFund = true,
nativeTokenContract = "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
)
println("Funded wallet at: ${fundedWallet.contractId}")