Skip to content
Devgo

Smart contract

Self-executing code on a blockchain. Smart contracts run when conditions are met, with no intermediary. Used for DeFi, NFTs, DAOs, and more. Written in Solidity (Ethereum) or other languages. Once deployed, they're immutable — bugs can't be fixed, funds can be lost.

When to use
  • DeFi (lending, trading, derivatives).
  • NFTs and digital ownership.
  • DAOs and governance.
  • Trustless agreements.
When not to
  • High-performance computation.
  • Apps needing updatable logic (immutability is a feature and a risk).
  • Private/confidential data.

Definition

A is code deployed to a that executes when called. It has functions, state, and rules. Calls are transactions (cost gas). Once deployed, the code is immutable (can't be changed). Solidity is the main language for . Audits are critical — bugs can lose millions.

Why it exists

To enable programmable, trustless agreements — code that automatically enforces rules (transfer money when condition X) without a middleman.

How it works

Write Solidity code. Compile to bytecode. Deploy as a transaction (costs gas). The contract gets an address. Users call functions by sending transactions. The EVM executes the code. State changes are recorded on-chain. Events emit . Upgradable patterns use proxies.

Scaling limits

Immutable — bugs can't be fixed (upgradable patterns exist but add complexity). Gas costs limit computation. On-chain storage is expensive. Slow (block times). Audits needed but not foolproof.

Cost shape

: gas cost. Each call: gas cost (varies with network demand). Audits: $10k-$100k+. Security is critical.

Alternatives

  • Traditional contracts + trusted intermediary — Updatable, private, but needs trust.
  • Off-chain computation + on-chain settlement — Faster, but some trust in the off-chain component.

Failure modes

  • Bugs leading to lost funds (immutable).
  • Reentrancy attacks.
  • Gas limits.
  • Oracle manipulation.
  • Front-running.

, , ,