Skip to main content

Smart Wallets

Smart wallets are the foundation of the SatsTerminal Borrow SDK. They provide secure, deterministic EVM accounts derived from Bitcoin wallet signatures.

What is a Smart Wallet?

A smart wallet is an ERC-4337 smart contract account that:
  • Is derived deterministically from a Bitcoin signature
  • Supports gasless transactions via account abstraction
  • Enables session-based authorization for secure operations
  • Provides multi-chain support with the same derivation

How Derivation Works

  1. User signs a deterministic message with their Bitcoin wallet
  2. The signature is used to derive EVM private keys
  3. A smart account address is computed from these keys
  4. The same BTC wallet always produces the same smart account

Signing Message Format

The Loan Wallet # index allows multiple smart accounts per BTC wallet.

Multi-Index Architecture

Each user can have multiple smart wallets, indexed starting from 0:

Why Multiple Wallets?

Using separate wallets per loan provides:
  1. Isolation - Each loan’s collateral is isolated
  2. Clarity - Clear separation of funds
  3. Security - Compromised loan doesn’t affect others
  4. Tracking - Easier transaction history per loan

Signature Caching

The SDK caches signatures to avoid repeated signing prompts:
Signatures are stored with namespaced keys:

Clearing Cached Signatures

Smart Account Features

Gasless Transactions

Smart accounts enable gasless transactions via ERC-4337:
  • Users don’t need ETH for gas
  • Gas is paid by the protocol
  • Transactions are bundled efficiently

Session Keys

Instead of signing every transaction, users authorize a session:
Sessions allow the SDK to execute transactions without additional signatures.

Cross-Chain Support

The same Bitcoin signature can be reused, but the smart account is still derived and checked in a chain-specific account context:

Wallet States

Deployed vs Undeployed

Smart accounts can exist in two states:
Deployment happens automatically during the first transaction.

Restoring Wallets

If a user switches devices, wallets can be restored:
The deterministic derivation ensures the same BTC wallet always recovers the same smart accounts.

Security Considerations

Signature Security

  • Signatures are stored locally (browser localStorage or provided storage)
  • Never transmitted except for initial derivation
  • Can be cleared via clearSession()

Smart Account Security

  • Controlled only by the derived keys
  • Session keys have limited scope and expiry
  • Multi-sig upgrades possible (future)

Best Practices

  1. Clear sessions on logout - Call clearSession() when user disconnects
  2. Use secure storage - Provide encrypted storage in production
  3. Monitor session expiry - Refresh sessions before they expire
  4. Validate addresses - Always verify smart account addresses match expectations