Feature: Implement Passkey Authentication & Smart Wallet Integration
Overview
The bounty frontend currently uses Better Auth for basic authentication but lacks passkey-based wallet creation and smart-account-kit integration. The main web (boundless) has a complete implementation including WebAuthn passkey registration, Soroban smart wallet deployment, and on-chain reputation initialization. This needs to be replicated in the bounty frontend.
Reference implementation: boundless/lib/smart-wallet/, boundless/components/providers/smart-wallet-provider.tsx, boundless/components/onboarding/SecureAccountStep.tsx
Goals
- Enable passkey-based authentication (biometrics / PIN)
- Deploy smart wallet contracts on Stellar for new users
- Store contractId + credentialId locally and sync with backend
- Initialize on-chain reputation profile during onboarding
- Support transaction signing via passkey for all contract interactions
Architecture (from Main Web)
The main web uses a two-layer auth system:
- Better Auth — Session management, email/password, Google OAuth
- smart-account-kit — Passkey registration, smart wallet deployment, transaction signing
Key Dependencies:
smart-account-kit v0.2.10
@stellar/stellar-sdk
- WebAuthn browser API
Implementation Details
1. Smart Wallet Configuration
Create: lib/smart-wallet/config.ts
Environment variables needed:
NEXT_PUBLIC_STELLAR_RPC_URL
NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE
NEXT_PUBLIC_SMART_ACCOUNT_WASM_HASH
NEXT_PUBLIC_WEBAUTHN_VERIFIER_ADDRESS
NEXT_PUBLIC_NATIVE_TOKEN_CONTRACT
NEXT_PUBLIC_SMART_WALLET_INDEXER_URL (optional)
NEXT_PUBLIC_SMART_WALLET_RELAYER_URL (optional)
2. Smart Wallet Client
Create: lib/smart-wallet/client.ts
Key functions:
getSmartAccountKit() — singleton instance
createSmartWallet(appName, userName) → { contractId, credentialId }
connectSmartWallet() → reconnect existing wallet
disconnectSmartWallet() → clear session
transfer(tokenContract, recipient, amount) — token transfers
fetchSacTokenBalance(tokenContract, walletContractId) — balance reads
3. Smart Wallet Provider
Create: components/providers/smart-wallet-provider.tsx
- Context with
contractId, credentialId, isConnected
- Persists to localStorage:
boundless:smart-wallet:{userId}
register(userName) — create new passkey + deploy wallet
connect() — reconnect existing passkey
disconnect() — clear state
- Syncs with backend via wallet API
4. Secure Account Onboarding Step
Create: components/onboarding/secure-account-step.tsx
- Biometric prompt for passkey creation
- Smart wallet deployment progress
- Fallback for browsers without WebAuthn support
- Success state with wallet address display
5. On-Chain Reputation Initialization
Create: lib/contracts/reputation-registry.ts
initReputationProfile(walletAddress) — calls Reputation Registry contract
- Signs with passkey via smart-account-kit
- Called at end of onboarding
6. Transaction Signing Integration
Create: lib/smart-wallet/sign.ts
- Generic
signAndSubmit(transaction) helper
- Passkey signing prompt for all contract interactions
- Used by all bounty contract hooks (claim, apply, submit, approve)
Files Affected
Created
lib/smart-wallet/config.ts
lib/smart-wallet/client.ts
lib/smart-wallet/sign.ts
lib/contracts/reputation-registry.ts
components/providers/smart-wallet-provider.tsx
components/onboarding/secure-account-step.tsx
Modified
package.json (add smart-account-kit, @stellar/stellar-sdk)
.env.example (add Stellar env vars)
providers/ (wrap app with SmartWalletProvider)
components/global-navbar.tsx (show wallet status)
Acceptance Criteria
Feature: Implement Passkey Authentication & Smart Wallet Integration
Overview
The bounty frontend currently uses Better Auth for basic authentication but lacks passkey-based wallet creation and smart-account-kit integration. The main web (
boundless) has a complete implementation including WebAuthn passkey registration, Soroban smart wallet deployment, and on-chain reputation initialization. This needs to be replicated in the bounty frontend.Reference implementation:
boundless/lib/smart-wallet/,boundless/components/providers/smart-wallet-provider.tsx,boundless/components/onboarding/SecureAccountStep.tsxGoals
Architecture (from Main Web)
The main web uses a two-layer auth system:
Key Dependencies:
smart-account-kitv0.2.10@stellar/stellar-sdkImplementation Details
1. Smart Wallet Configuration
Create:
lib/smart-wallet/config.tsEnvironment variables needed:
2. Smart Wallet Client
Create:
lib/smart-wallet/client.tsKey functions:
getSmartAccountKit()— singleton instancecreateSmartWallet(appName, userName)→{ contractId, credentialId }connectSmartWallet()→ reconnect existing walletdisconnectSmartWallet()→ clear sessiontransfer(tokenContract, recipient, amount)— token transfersfetchSacTokenBalance(tokenContract, walletContractId)— balance reads3. Smart Wallet Provider
Create:
components/providers/smart-wallet-provider.tsxcontractId,credentialId,isConnectedboundless:smart-wallet:{userId}register(userName)— create new passkey + deploy walletconnect()— reconnect existing passkeydisconnect()— clear state4. Secure Account Onboarding Step
Create:
components/onboarding/secure-account-step.tsx5. On-Chain Reputation Initialization
Create:
lib/contracts/reputation-registry.tsinitReputationProfile(walletAddress)— calls Reputation Registry contract6. Transaction Signing Integration
Create:
lib/smart-wallet/sign.tssignAndSubmit(transaction)helperFiles Affected
Created
lib/smart-wallet/config.tslib/smart-wallet/client.tslib/smart-wallet/sign.tslib/contracts/reputation-registry.tscomponents/providers/smart-wallet-provider.tsxcomponents/onboarding/secure-account-step.tsxModified
package.json(addsmart-account-kit,@stellar/stellar-sdk).env.example(add Stellar env vars)providers/(wrap app with SmartWalletProvider)components/global-navbar.tsx(show wallet status)Acceptance Criteria