Risk & Security
Smart Contract Audit
A smart contract audit is an independent security review of on-chain code designed to identify vulnerabilities before they can be exploited.
A self-executing program on a blockchain that automatically enforces agreement terms when predefined conditions are satisfied.
A smart contract is a self-executing program stored on a blockchain that automatically enforces the terms of an agreement when predefined conditions are met. No intermediary, administrator, or trusted third party is required — the code itself serves as the arbiter of the contract's terms. Smart contracts are the foundational building block of decentralized finance, enabling everything from token swaps and lending to complex multi-step financial instruments to operate without centralized control.
A smart contract is deployed to a blockchain as compiled bytecode at a specific address. Once deployed, the contract's code is immutable — it cannot be changed (unless the contract is specifically designed with upgrade mechanisms). Anyone can interact with the contract by sending a transaction to its address with the appropriate function call and parameters.
The blockchain's virtual machine executes the contract's logic deterministically: given the same inputs and state, the contract will always produce the same outputs. This determinism is what makes smart contracts trustworthy — users can verify exactly what the code will do before interacting with it, and the execution cannot be altered or censored by any single party.
On Ethereum and EVM-compatible chains (Arbitrum, Optimism, BASE, Polygon, BSC), smart contracts are typically written in Solidity or Vyper and compiled to EVM bytecode. The Ethereum Virtual Machine processes every transaction identically across all nodes in the network, ensuring consensus on the contract's state.
Other blockchain platforms support smart contracts through their own runtimes. Solana uses Rust and C for its programs, Aptos and Sui use the Move language, and CosmWasm-based chains use Rust compiled to WebAssembly. While the languages differ, the core concept remains the same: deterministic code that runs on a decentralized network without requiring trust in any single operator.
Smart contracts are the engine that powers every DeFi lending protocol. In a traditional loan, a bank evaluates your creditworthiness, sets terms, manages the collateral, and enforces repayment. In DeFi, smart contracts handle all of these functions autonomously:
When a borrower deposits collateral into a lending protocol, a smart contract receives and holds those assets. The contract tracks the collateral's value using price data from oracles and continuously calculates the borrower's health factor. No human custodian touches the assets at any point.
Lending protocol smart contracts implement interest rate models that algorithmically adjust borrowing and supply rates based on pool utilization. These calculations happen on every block, accruing interest in real time without any manual intervention.
If a borrower's collateral value drops below the required threshold, the smart contract opens the position for liquidation. Liquidator bots interact directly with the contract to repay part of the debt in exchange for discounted collateral. The entire process — from detection to execution — happens on-chain without any human decision-maker.
Because smart contracts enforce rules through code rather than identity checks, anyone with a wallet can participate. There is no application process, no credit check, and no approval delay. This permissionless access is what allows DeFi lending to serve users globally, regardless of their jurisdiction or background.
Because smart contracts control real funds — billions of dollars across major DeFi protocols — security is paramount. A single vulnerability in a smart contract can lead to catastrophic fund losses, and unlike traditional software bugs, exploited smart contracts often cannot be patched after the fact.
Smart contract vulnerabilities include reentrancy attacks (where an attacker repeatedly calls back into a contract before previous executions complete), integer overflow/underflow errors, access control flaws, oracle manipulation, and flash loan attack vectors. The composable nature of DeFi means that a vulnerability in one contract can often be exploited through interactions with other protocols.
Smart contract audits by independent security firms are standard practice before a protocol launches. Auditors review the code for known vulnerability patterns, logic errors, and economic attack vectors. However, audits are not guarantees — they are point-in-time assessments that reduce but do not eliminate risk. Some of the largest DeFi exploits have occurred in audited contracts.
Beyond audits, mature protocols employ multiple layers of security: formal verification (mathematically proving code correctness), bug bounty programs that reward white-hat hackers for finding vulnerabilities, time-locked upgrades that give users time to exit before changes take effect, and on-chain monitoring systems that can pause contracts if anomalous activity is detected.
A key design decision in smart contract architecture is whether to make contracts upgradeable. Immutable contracts provide stronger security guarantees — users know the code will never change — but they cannot be patched if a bug is discovered. Upgradeable contracts (typically implemented through proxy patterns) allow developers to fix bugs and add features, but they introduce trust assumptions about who controls the upgrade process.
Most major DeFi protocols use upgradeable contracts governed by DAOs or multisig wallets, with time-lock delays that give users advance notice of any changes. This represents a pragmatic middle ground between immutability and the practical need to evolve the protocol over time.
Smart contracts fundamentally change the trust model of financial services. Instead of trusting an institution's promise to honor its obligations, users trust publicly verifiable code that executes identically for everyone. This shift from institutional trust to algorithmic trust is what makes DeFi possible and is the reason that billions of dollars flow through smart contracts daily. For borrowers and lenders, smart contracts provide transparent, predictable, and censorship-resistant financial services that operate around the clock without gatekeepers.
Related Terms
Risk & Security
A smart contract audit is an independent security review of on-chain code designed to identify vulnerabilities before they can be exploited.
DeFi Fundamentals
An ecosystem of financial applications built on blockchains that use smart contracts to provide services without traditional intermediaries.
Blockchain & Networks
Ethereum is a programmable blockchain platform that powers smart contracts and serves as the foundation for most decentralized finance applications.
DeFi Fundamentals
A DeFi protocol is a set of smart contracts on a blockchain that delivers financial services like lending, trading, or yield without centralized intermediaries.