> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theblockchainlibrary.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart Contract

> A smart contract is a self-executing program stored on a blockchain that automatically runs when predetermined conditions are met. These contracts eliminate the need for intermediaries by encoding terms directly into lines of code, ensuring that the agreement is enforced exactly 

# Smart Contract

A smart contract is a self-executing program stored on a blockchain that automatically runs when predetermined conditions are met. These contracts eliminate the need for intermediaries by encoding terms directly into lines of code, ensuring that the agreement is enforced exactly as written without human interference. Because they reside on an immutable ledger, the execution results are verifiable, transparent, and impossible to tamper with once deployed.

## Definition

A smart contract is a self-executing program stored on a blockchain that automatically runs when predetermined conditions are met. These contracts eliminate the need for intermediaries by encoding terms directly into lines of code, ensuring that the agreement is enforced exactly as written without human interference. Because they reside on an immutable ledger, the execution results are verifiable, transparent, and impossible to tamper with once deployed.

## Simple explanation

A smart contract is like a digital vending machine. You put your money in, and if you choose the right code for a snack, the machine automatically gives it to you. You don't need a store clerk to watch the transaction because the machine handles the deal perfectly every time.

## Why it matters

Smart contracts enable the creation of complex decentralized finance (DeFi) applications, NFTs, and autonomous organizations. They fundamentally change how we build digital trust and automated agreements.

## How it works

Developers write the contract in a programming language (like Solidity). Once deployed to the blockchain, the contract sits at a specific address. When a user sends a transaction to that address, the code executes its logic and updates the blockchain state accordingly.

## Real-world example

Uniswap uses smart contracts to handle automated token swaps without a central exchange.

## Advantages

* Automated execution
* No intermediary required
* Immutable and verifiable

## Limitations

* Bugs can cause losses
* Hard to update code
* High gas costs

## Common misconceptions

* They are not 'legal' contracts in all jurisdictions.
* They are not intelligent or self-aware.

## Related knowledge

* [DeFi](/categories/defi) — term
* [Ethereum](/categories/ethereum) — term
* [Immutability](/generated/v2/glossary/immutability) — term
* [Solidity](/generated/v2/resources/solidity) — term

***

**Canonical knowledge ID:** `glossary:smart-contract`
