Smart accounts and account abstraction
Ethereum has two kinds of accounts. An externally owned account, or EOA, is controlled by a private key and is the only kind that can start a transaction. A contract account is controlled by code. Account abstraction means letting a wallet's rules be written as code, so it can offer social recovery, spending limits, multiple keys or passkeys instead of relying on one fragile private key.
ERC-4337 made this possible without changing Ethereum itself. Users sign a UserOperation instead of a transaction. Bundlers collect these operations and submit them through a shared EntryPoint contract, which asks each smart account to validate its operation before running it.
Newer proposals go further. EIP-7702, activated in the Pectra upgrade in 2025, lets an ordinary EOA delegate to contract code, so existing addresses can gain smart-wallet features such as batching and sponsored gas without moving funds.
The example shows the core idea in a simplified wallet: the owner signs a request off-chain, and anyone can submit it and pay the gas. The signed data includes the chain ID, the wallet address and a nonce, so a signature cannot be replayed. It is for learning only. In production use audited wallets such as Safe or the ERC-4337 reference accounts.
contract SimpleWallet { address public immutable owner; uint256 public nonce; constructor(address o) { require(o != address(0), "Zero owner"); owner = o; } receive() external payable {} function execute(address to, uint256 value, bytes calldata data, bytes calldata sig) external { bytes32 h = keccak256(abi.encode(block.chainid, address(this), nonce, to, value, keccak256(data))); bytes32 digest = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", h)); require(_recover(digest, sig) == owner, "Bad signature"); nonce++; // each signature works once (bool ok, ) = to.call{value: value}(data); require(ok, "Call failed"); } function _recover(bytes32 digest, bytes calldata sig) internal pure returns (address) { require(sig.length == 65, "Bad signature length"); bytes32 r; bytes32 s; uint8 v; assembly { r := calldataload(sig.offset) s := calldataload(add(sig.offset, 32)) v := byte(0, calldataload(add(sig.offset, 64))) } return ecrecover(digest, v, r, s); } }
Try it yourself
Add a second key called guardian that can replace the owner after a delay, a simple form of social recovery. Think about why the nonce must change on every call.
Press Compile to check your code in the browser. Short fragments are wrapped in a contract automatically.