BlockchainAppMaker Get a quote

DeFi

DeFi wallet development: custody models, smart accounts and signing safety

DeFi wallet development is the work of building a self-custody wallet that holds keys, connects to DeFi apps and shows users what they sign. This guide covers custody models, smart accounts, signing safety, features, form factors and cost.

Secure key storage has standard solutions, but two problems are harder: stopping users from signing transactions that drain their funds, and restoring access after a lost device without a custodian. For general wallet architecture, see cryptocurrency wallet development, and for a browser-extension wallet similar to a well-known product, see MetaMask-like wallet development.

What a DeFi wallet does

Any self-custody crypto wallet can hold tokens. A DeFi wallet adds features for using protocols:

  • It connects to DeFi apps in a browser or on a phone.
  • It simulates each transaction and shows the expected balance changes.
  • It decodes approvals and signature requests into plain language.
  • It offers swaps and bridges inside the wallet.
  • It tracks positions across protocols, such as liquidity, loans and staking.

In a crypto DeFi wallet, the user holds the keys, so no company can freeze or move the funds, but for the same reason none can reverse a harmful transaction that the user signed.

Custody models

ModelHow keys workRecoveryAdvantages and limits
Seed phrase with an externally owned account (EOA)A BIP-39 phrase derives keys through BIP-32 and BIP-44 paths, for example m/44'/60'/0'/0/0 for EthereumThe user backs up the seed phraseWorks with every app. Users lose or leak phrases, and the account has no spending rules.
Hardware-backed keyThe key stays in a secure chip or in the phone's secure enclaveA seed backup, or a method tied to the deviceStrong against malware. Phone enclaves use the P-256 curve, and Ethereum accounts use a different curve. An EVM account therefore needs smart account code to accept an enclave key.
Multi-party computation (MPC)The key is split into shares held by the device, the provider and a backup. The full key is never assembled.The remaining shares create new sharesNo seed phrase. The wallet depends on the provider staying online and on a correct MPC protocol.
Smart contract accountA contract wallet with its own validation rules, such as multisig, passkeys or session keysGuardians or social recoveryThe most flexible model. Deployment costs gas on each chain, and a few apps still expect an EOA.

MPC and smart accounts can work together, because an MPC key can sign for a smart account. A provider that can move user funds on its own runs a custodial wallet, even if it markets the wallet as self-custody. Custodial wallets carry regulatory consequences in many countries.

Smart accounts: ERC-4337 and EIP-7702

ERC-4337 lets an account run its own validation code, which is called account abstraction. It needed no change to Ethereum's consensus rules. Users sign UserOperations, and servers called bundlers collect them and send them to a shared EntryPoint contract, which runs each account's validation logic. Paymaster contracts can pay the gas or accept payment in ERC-20 tokens. ERC-4337 supports four useful features:

  • Batching. The user approves and swaps in one action, so no unlimited approval is left behind.
  • Gas sponsorship. Users without ETH can still send transactions.
  • Session keys. A limited key can, for example, trade on one DEX up to a set amount for one hour, and games and trading bots use such keys.
  • Passkeys and recovery. The account accepts WebAuthn passkeys and lets guardians restore access.

EIP-7702 went live with Ethereum's Pectra upgrade in May 2025 and lets an existing EOA delegate to smart contract code, so users keep their address and gain batching and gas sponsorship.

EIP-7702 also created a new kind of phishing, in which a malicious delegation signature gives control of the account to the attacker's code. A wallet that supports EIP-7702 should allow delegation only to reviewed implementations, and it should show a strong warning for any other target.

The Fusaka upgrade of December 2025 added a precompile, which is a contract built into the protocol, for the P-256 curve (EIP-7951), so smart accounts can now verify passkey and secure enclave signatures on Ethereum mainnet at low gas cost.

Signing safety in DeFi wallet development

Most individual losses in DeFi come from signing something harmful, not from stolen keys, so a DeFi wallet should make every signature understandable.

Transaction simulation

Simulate every transaction against current chain state. Show the result as balance changes, for example "You send 1,000 USDC. You receive at least 0.31 ETH." Flag transfers to unknown contracts, approvals and ownership changes.

Simulation has limits: chain state can change before the transaction is included in a block, and some malicious contracts detect a simulation and behave differently there. Combine simulation with the approval, signature and address checks below.

Approvals and permits

  • Default to approvals for the exact amount, and show who the spender is.
  • Decode EIP-2612 permit and Permit2 signatures. A permit signature looks like a harmless message, but it lets another address spend the user's tokens. Many drainer kits, which are ready-made phishing tools, depend on users signing permits without reading them.
  • Provide an approvals page where users can revoke old allowances.

Typed data and messages

Show EIP-712 typed data in readable form. Block raw eth_sign requests that sign a bare hash, or show a strong warning, because such a signature can authorize any action and the user cannot see which one.

Address and domain checks

Warn users about address poisoning, in which a scammer sends a tiny transfer from an address that looks like one in the user's history. Warn also about known drainer contracts, newly deployed contracts and phishing domains. Keep block lists up to date and use shared threat feeds.

Warnings in the right places

A wallet should add extra steps only to risky actions. A routine swap through a known router needs one confirmation, while unlimited spending for a contract deployed yesterday, or an EIP-7702 delegation to unknown code, needs a warning and an extra confirmation.

When every action shows the same pop-up, users learn to click through all of them, and drainer kits rely on that habit. Record which warnings users ignore and use that data to improve the warnings, but keep the protection in place.

DeFi features users expect

  • Swaps, usually through an aggregator API that pays the wallet an integrator fee. The white-label swap guide compares options.
  • Bridging between chains through bridge aggregators. The wallet should name the bridge in use and its risks.
  • Portfolio and positions, including liquidity positions, lending health factors and staking balances. This feature needs indexing for every supported protocol.
  • App connection through an injected provider (EIP-1193), which apps find through EIP-6963, while mobile wallets use WalletConnect.
  • MEV protection through optional private transaction submission, which reduces sandwich attacks. In a sandwich attack, a bot trades just before and just after the user and takes the price difference.
  • Multichain support. EVM chains share one key format, but Solana, Bitcoin and other chains need separate derivation and signing code.

Form factors

One wallet core can ship in several form factors, and each form factor changes the security model:

  • Browser extension. Most desktop DeFi users use an extension, which injects a provider into web pages and must keep keys away from page scripts. The main risks are malicious updates, a compromised build pipeline and fake copies in extension stores.
  • Mobile app. A mobile wallet can use the phone's secure hardware and biometrics, and it connects to desktop apps through WalletConnect or deep links. App store rules on crypto features differ by region and change, so plan for review delays.
  • Hardware wallet support. Support for established hardware signers lets careful users keep keys offline while they use your interface. Clear signing matters here: the device shows decoded transaction details, so users do not approve unreadable contract calls on a small screen.
  • Embedded or web wallet. This wallet lives inside an app, often with email or passkey login and MPC or a smart account underneath. Sign-up is easiest, but users must trust the provider's servers and recovery process.
  • DeFi dashboard over a smart account. Some products act as a control panel that groups positions across protocols and runs multi-step actions in one transaction. Smart contract wallets with add-on modules can run these actions.

Many teams start with one form factor and a shared signing core and add other forms later. Keep the transaction decoding and risk checks in one library, so that every form factor warns users in the same way.

Build process

  1. Choose the custody model and the recovery method for your audience. Experienced crypto users accept seed phrases, while mainstream users need passkeys or MPC with a recovery path.
  2. Choose the platforms: browser extension, mobile app or a wallet embedded in another app. Each platform has its own key storage and its own store review rules.
  3. Use audited cryptography libraries. Never write your own key derivation or signature code.
  4. Build the signing pipeline in five stages: decode, simulate, check risk, display and sign.
  5. Integrate DeFi services, including aggregators, price data, indexing and RPC providers with fallbacks.
  6. Run a security review of key storage, memory handling, extension permissions and the update channel. Audit any smart account contracts.
  7. Operate the wallet. Update threat feeds, prepare an incident response plan and sign every release, because a compromised wallet update can empty every user's account at once.

DeFi wallet development cost and timeline

The figures below are estimates, not quotes. An EVM wallet on one platform, built on established libraries, with aggregator swaps and basic simulation, might take three to five engineers four to six months.

A wallet on several platforms with smart accounts, MPC, many chains and detailed portfolio tracking takes more than a year, and it also has running costs for RPC access, simulation, indexing and security operations.

Cost driverWhy it adds cost
Number of platformsThe extension, iOS and Android apps each need native key storage and testing
Non-EVM chainsEach chain has its own curves, derivation paths, transaction formats and RPC servers
MPC or smart accountsMPC adds provider fees. Smart accounts add contract audits and bundler and paymaster servers.
Simulation and threat dataSimulation servers and risk lists need constant upkeep
Portfolio coverageEach supported protocol needs its own position decoding

For an app with an embedded wallet, the DeFi app development guide covers embedded wallets inside apps, and the Web3 wallet guide covers wallets for uses beyond DeFi.

This page is general information, not legal advice. Wallet regulation often depends on whether the provider can control user funds. Custodial designs, and MPC designs where the provider controls the key, may need a license in some countries.

Frequently asked questions

What is a DeFi wallet?

A DeFi wallet is a self-custody wallet with features for using DeFi protocols. It connects to apps, simulates transactions, manages approvals, offers swaps and bridges, and tracks positions across protocols.

Is MPC safer than a seed phrase?

With MPC, the user has no seed phrase to lose, and recovery is easier, but MPC adds a dependence on the provider that holds a share and on the correctness of the MPC protocol. A seed phrase fails when the user loses or leaks it, while MPC fails when the provider goes offline or the protocol has a bug.

Should a wallet use ERC-4337 or EIP-7702?

A wallet can use both. ERC-4337 provides the infrastructure, which includes bundlers, paymasters and the EntryPoint contract. EIP-7702 lets existing EOAs run smart account code. Many wallets give new users a smart account and let existing users upgrade their current address.

How do wallets prevent drainer attacks?

Wallets simulate transactions, decode permits and approvals, and check addresses and domains against threat lists, and they show clear warnings before risky actions. No single check stops every attack, so wallets combine several.

How should a mobile wallet store keys?

A mobile wallet should use the phone's secure hardware, which is the Secure Enclave on iOS and the Android Keystore on Android. The wallet encrypts the seed with a key that never leaves that hardware and asks for biometrics before each signature.