If you have used Ethereum to swap tokens, buy an NFT or deposit crypto into a decentralised finance (DeFi) protocol, you have probably interacted with a smart contract. You may not have seen the contract itself—you likely connected a wallet, selected an action and confirmed a transaction—but smart-contract code handled the on-chain part of the process.
Smart contracts are one of the main reasons Ethereum can do more than transfer ETH. They allow developers to build applications that follow blockchain-based rules rather than relying entirely on a centralised company or server. These applications are commonly called decentralised applications, or dApps.
This guide explains how Ethereum smart contracts and dApps work, where gas and the Ethereum Virtual Machine (EVM) fit in, what these applications can do, and the risks to understand before signing a transaction.
Visit the Ethereum detail page for the live chart, market data and technical analysis.
An Ethereum smart contract is a program deployed to a specific address on the Ethereum blockchain. Its code contains functions and data that determine how it behaves when users or other contracts interact with it.
Developers commonly write Ethereum smart contracts in Solidity. The code is compiled into bytecode that the Ethereum Virtual Machine (EVM) can execute.
Once deployed, a contract can receive transactions and run its programmed logic. A decentralised exchange, for example, can use contracts to apply swap rules, move tokens and update balances. A lending protocol can use them to track deposits, collateral, borrowing and repayments.
The key point is that the on-chain logic runs according to code. There is no employee manually approving each transaction.
Also read: What Is Ethereum?
You do not need to learn Solidity to understand smart contracts, but this small example shows what the code can look like:
function setNumber(uint256 _number) public {
number = _number;
}
This function changes a value stored by the contract. In simple terms, the process is:
Solidity code → deployed smart contract → user interaction → EVM execution → recorded state change

From a user’s perspective, a state-changing interaction usually follows these steps:
Execution flow: Wallet → dApp → Smart contract → EVM → Ethereum network → Confirmed transaction

Also Read: What is Ethereum Wallet
Gas measures the computational work required to execute an operation on Ethereum. Any on-chain transaction that changes Ethereum’s state requires gas. A simple ETH transfer between ordinary accounts commonly uses 21,000 gas, while a token swap can use substantially more because it may involve several contract operations.
Gas units are not fixed currency prices. The amount paid depends on how much gas the transaction uses, the applicable fee per unit of gas and the price of ETH. Ethereum’s fee mechanism includes a protocol-set base fee, which is burned, and a priority fee that can go to the block proposer.
Not every contract interaction costs gas. Reading public contract data without changing Ethereum’s state can be performed as a local call and does not require an on-chain transaction. Actions such as swapping, transferring tokens, minting or changing stored data require a transaction and gas.

Contracts can emit events when transactions execute. Wallets, explorers and dApp interfaces use these logs to display activity such as transfers, swaps and approvals. Events help describe what happened, although the contract’s stored state remains the authoritative source for its current data.
Token approvals are another common interaction. Under ERC-20-style allowance systems, a user can authorise a spender to move up to an approved amount of a token. This is why a swap may require an approval transaction before the swap itself. Always check the token, spender address and allowance before approving access.
A dApp, or decentralised application, is an application that uses blockchain-based functionality, usually through one or more smart contracts.
From the user’s side, a dApp can look like an ordinary website. You connect a wallet, choose an action and confirm it. The difference is that important logic or state changes can be handled on-chain instead of only inside a company’s private database.
For example, Uniswap lets users interact with contracts to swap tokens, while Aave uses smart contracts for DeFi lending and borrowing. The dApp provides the user-facing experience, while its smart contracts provide the on-chain logic.
A dApp is not necessarily decentralised in every component. Its frontend may be hosted conventionally, and it may depend on wallet providers, indexers, oracles or other off-chain services. The term “dApp” therefore describes its use of decentralised infrastructure, not a guarantee that every component is decentralised.
Also Read: ETH Liquidation Map
| Feature | Smart contract | dApp |
|---|---|---|
| What it is | Code and state deployed on-chain | A user-facing application and its supporting components |
| Main role | Executes programmed blockchain logic | Helps users interact with blockchain functionality |
| Typical components | Functions, storage and events | Frontend, wallet connection, contracts and external services |
| Can it exist alone? | Yes | Usually depends on contracts or other blockchain services |
A simple way to remember the difference is: the smart contract handles the on-chain logic; the dApp gives users a way to interact with it.
Smart contracts can hold tokens, enforce rules and update their state when users interact with them. Combine several contracts with a frontend and wallet connection, and developers can build complete financial or digital applications on Ethereum.

DeFi is one of Ethereum’s largest smart-contract use cases. Decentralised exchanges can facilitate token swaps directly from users’ wallets. Lending protocols can manage deposits, collateral, borrowing and repayments according to on-chain rules.
These systems reduce the need for a traditional intermediary to process every action, but users still depend on the protocol’s code, economic design and supporting infrastructure.
NFT smart contracts can define ownership, transfers and other rules for unique digital assets. ERC-721 is widely used for non-fungible tokens, while ERC-1155 can represent multiple asset types within one contract.
NFT marketplaces such as OpenSea use smart contracts to support activities such as listing, buying and transferring NFTs. The associated image or media may be stored outside Ethereum, even when ownership and transaction history are represented on-chain.
A decentralised autonomous organisation (DAO) can use smart contracts to manage proposals, voting and treasury actions. Depending on the design, eligible members may vote on a proposal and a contract may execute the approved result.
This can reduce manual processing, but governance still depends on factors such as voting rules, token distribution, permissions and the security of treasury contracts.
Smart contracts cannot independently fetch arbitrary information from the outside world. Oracle systems bring data such as asset prices on-chain so contracts can use it.
Chainlink is one oracle infrastructure provider used in the Ethereum ecosystem. A lending protocol, for example, may rely on an oracle price to determine whether a borrower’s collateral is sufficient.
This creates an additional dependency. If the input data is wrong, delayed or manipulated, a protocol can make an incorrect decision even when its code works as written.
Ethereum standards define common ways for tokens, wallets and applications to work together.
| Standard | Common use |
|---|---|
| ERC-20 | Fungible tokens, where units of the same token are interchangeable |
| ERC-721 | Non-fungible tokens, where individual tokens are unique |
| ERC-1155 | Multiple token types, including fungible and non-fungible assets |
| ERC-4337 | Account abstraction and smart-contract-based wallet functionality |

ERC-20, ERC-721 and ERC-1155 define token interfaces. ERC-4337 is different: it focuses on account abstraction rather than defining a token format.
One of Ethereum’s major strengths is composability. Smart contracts can act as public building blocks that interact with other contracts. Developers can reuse token standards, liquidity pools, lending systems, oracles and other on-chain components instead of rebuilding everything from scratch.
For example, one application could support an ERC-20 token, obtain external data through an oracle and interact with an existing lending protocol. This ability to build on shared infrastructure has helped create an interconnected dApp ecosystem.
Composability also creates dependency risk. If one component is exploited, misconfigured or supplied with bad data, other applications that rely on it may be affected.
Also read: Ethereum Price Prediction
Smart contracts make Ethereum programmable, but automation does not make them automatically safe. The blockchain executes the transaction a user authorises, so understanding what is being signed matters.
Bugs or design flaws can cause unintended behaviour and, in some cases, the loss of funds. Reentrancy is one well-known vulnerability class: a contract can be called again before it has finished updating its state.
Imagine a vulnerable withdrawal function that sends funds before reducing the user’s stored balance. A malicious contract may call the withdrawal function again before the balance is updated, potentially repeating the withdrawal.

The 2016 DAO exploit is a historic example associated with reentrancy. The incident affected a large amount of ether and contributed to the chain split that resulted in Ethereum and Ethereum Classic.
Projects often audit and test their contracts before deployment. Audits can identify potential problems, but they cannot prove that a contract is completely secure.
Some contracts are designed to be immutable, while others use upgrade mechanisms or privileged roles. Upgradeability can help developers fix problems, but it also creates trust assumptions. Users should understand who can change the logic, pause the system or modify important parameters.
An approval can allow a contract or address to spend up to a specified amount of a token. Excessive or unnecessary allowances increase exposure if the spender is malicious or compromised.
Before approving access, check:
Review existing allowances periodically and revoke permissions that are no longer needed.
A contract may behave exactly as coded and still produce a harmful outcome because an oracle, another contract or an off-chain service failed. Evaluate the important dependencies behind a protocol, not only its main contract.
A malicious website can imitate a legitimate dApp and trick users into connecting a wallet or signing a harmful transaction. Use verified links, check the website address and be cautious with links from social media, messaging apps, emails or unexpected messages.
Never enter a seed phrase into a dApp to “connect,” “verify” or “recover” a wallet. A legitimate dApp does not need the seed phrase.
Confirmed blockchain transactions generally cannot be cancelled by a central authority. If a user signs a malicious transaction and funds are transferred, recovery may be difficult or impossible.
Also Read: ETH Liquidation Map
You do not need to be a Solidity developer to adopt safer habits:
If a transaction or permission request does not make sense, stop and investigate it before signing.
Ethereum smart contracts are the programmable layer behind much of the Ethereum ecosystem. They make token swaps, lending, NFTs, community governance and oracle-powered applications possible. dApps give users a convenient interface for accessing this functionality, while smart contracts handle the on-chain logic.
However, smart contracts are not automatically safe. Code bugs, risky permissions, upgrade controls, compromised dependencies and fake interfaces can all create risk. The safest approach is to understand what a transaction will do, verify where it is going and avoid approving permissions you do not understand.
To keep learning, explore Mudrex Learn and follow the Mudrex YouTube channel for practical crypto education. Always assess product, custody, market and protocol risks before committing funds.
A Ethereum smart contract is a program deployed at an Ethereum address. It contains functions and state that execute according to its code when users or other contracts interact with it.
A dApp is an application that uses blockchain functionality, often through smart contracts. It may also use a conventional frontend, wallet connection and off-chain services.
No. The smart contract is the on-chain code. A dApp is the broader application used to access one or more contracts and related services.
Ethereum nodes execute smart-contract bytecode in the EVM. Validators participate in consensus and help determine the canonical blockchain state.
No. Read-only calls that do not change Ethereum state can be queried without an on-chain transaction. State-changing writes require a transaction and gas.
It depends on the design. Some contracts are immutable, while upgradeable systems can change logic through defined mechanisms. Users should check who controls upgrades and permissions.
No. Contracts can contain bugs or flawed economic logic and may depend on oracles, admins or other contracts. Security audits can reduce uncertainty but cannot guarantee safety.
A token approval authorises a contract or address to spend up to an allowed amount of a token. Review the spender and allowance before approving it.
Reentrancy occurs when a contract is called again before it has completed an earlier operation and updated its state. In a vulnerable design, this may allow an action such as a withdrawal to repeat unexpectedly.