{
  "$schema": "https://degreesofsatoshi.com/encyclopedia/schemas/article-v1.json",
  "schemaVersion": "1.0.0",
  "id": "ethereum-smart-contracts",
  "canonical": "https://degreesofsatoshi.com/encyclopedia/ethereum-smart-contracts/",
  "collection": "ethereum",
  "title": "Smart contracts: programmed rules, examples and outside promises",
  "description": "Follow a simple escrow example to understand contract code, state, authorization, external data and the difference between execution and a real promise.",
  "aliases": [
    "smart contract explained",
    "onchain program"
  ],
  "dates": {
    "published": "2026-10-02",
    "modified": "2026-10-02",
    "verified": "2026-10-02T18:16:35.976Z",
    "dataAsOf": null
  },
  "authorship": {
    "publisher": "Degrees of Satoshi editorial project",
    "process": "AI-assisted research and drafting with a separate automated source-verification pass; no external expert or named human review is implied."
  },
  "quickAnswer": {
    "text": "A smart contract is code and stored data at a blockchain address. A transaction can invoke its functions, and nodes check the resulting execution. The contract enforces its programmed conditions; it cannot independently know whether an outside event happened, and correct execution does not prove that its rules are safe or fair.",
    "claimId": "ethereum-smart-contracts-quick-answer",
    "sourceIds": [
      "contracts",
      "evm"
    ]
  },
  "keyFacts": [
    {
      "label": "Components",
      "value": "Code plus persistent state",
      "sourceIds": [
        "contracts"
      ],
      "id": "components",
      "claimId": "ethereum-smart-contracts-fact-components"
    },
    {
      "label": "Invocation",
      "value": "Transactions or calls trigger execution",
      "sourceIds": [
        "transactions",
        "contracts"
      ],
      "id": "invocation",
      "claimId": "ethereum-smart-contracts-fact-invocation"
    },
    {
      "label": "Outside information",
      "value": "Needs an external input mechanism such as an oracle",
      "sourceIds": [
        "contracts"
      ],
      "id": "outside-information",
      "claimId": "ethereum-smart-contracts-fact-outside-information"
    }
  ],
  "prerequisites": [
    "what-is-ethereum",
    "ethereum-transactions-and-nonces"
  ],
  "sections": [
    {
      "id": "rules-and-state",
      "heading": "Code supplies the rule; state records the current position",
      "sourceIds": [
        "contracts",
        "evm"
      ],
      "paragraphs": [
        "A contract can contain a rule that a particular signer may release funds, while storage records how much is deposited and whether release has already occurred. Nodes re-execute the rule when evaluating a transaction.",
        "The familiar phrase self-executing can mislead. A contract does not wake itself because a calendar date arrived; a transaction or another execution path must trigger the action, and somebody supplies the required fee."
      ]
    },
    {
      "id": "escrow-example",
      "heading": "Example: an escrow can check a signature but not a delivery van",
      "sourceIds": [
        "contracts",
        "accounts"
      ],
      "paragraphs": [
        "Imagine a contract holding 0.05 ETH until a designated buyer approves release. It can verify the buyer’s authorization and transfer the funds when its conditions hold. Repeated release can be blocked by stored state.",
        "It cannot inspect a parcel on its own. If release depends on delivery, the design needs a trusted signer, an oracle or some dispute arrangement. That external dependency is part of the product even though the transfer is onchain."
      ]
    },
    {
      "id": "read-and-write",
      "heading": "A preview and an included failed call have different effects",
      "sourceIds": [
        "edition-eth-jsonrpc",
        "edition-eip140",
        "edition-eip658",
        "edition-eth-gas",
        "edition-solidity-delegatecall"
      ],
      "paragraphs": [
        "An eth_call runs against a selected state without publishing a transaction. It can show a return value or failure under those inputs, but does not establish that a later signed transaction will see the same state.",
        "An included transaction that reverts rolls back its execution’s state changes while still paying for consumed gas. REVERT can preserve unused gas; it does not refund all work already done. A caught nested failure can coexist with a successful top-level receipt, so inspect the actual application result."
      ]
    },
    {
      "id": "change-and-risk",
      "heading": "A fixed address can still sit inside a changeable application",
      "sourceIds": [
        "upgrading",
        "contracts"
      ],
      "paragraphs": [
        "Some applications use proxy patterns or configuration controls that let authorized parties change behavior. The address remaining the same does not establish that the rules or implementation remain the same.",
        "Conversely, fixed code can preserve a bug as effectively as a useful rule. To understand a contract, identify both its executable conditions and its control structure, rather than treating smart as a quality guarantee."
      ]
    }
  ],
  "faq": [
    {
      "question": "Is a smart contract necessarily a legal contract?",
      "answer": "The technical term describes a program. Its name does not by itself establish a legal agreement, enforceable rights or a real-world counterparty.",
      "sourceIds": [
        "contracts"
      ]
    },
    {
      "question": "Can a smart contract fetch a website by itself?",
      "answer": "Ordinary contract execution cannot independently retrieve arbitrary offchain information. An oracle or another submitted input must bring that information into the system.",
      "sourceIds": [
        "contracts"
      ]
    },
    {
      "question": "Does a contract always need a website?",
      "answer": "No. A website is one interface. The contract can remain callable through other compatible software if its code, network and access conditions permit it.",
      "sourceIds": [
        "interacting"
      ]
    }
  ],
  "claims": [
    {
      "id": "ethereum-smart-contracts-quick-answer",
      "articleSlug": "ethereum-smart-contracts",
      "statement": "A smart contract is code and stored data at a blockchain address. A transaction can invoke its functions, and nodes check the resulting execution. The contract enforces its programmed conditions; it cannot independently know whether an outside event happened, and correct execution does not prove that its rules are safe or fair.",
      "sourceIds": [
        "source-1bffcf35253de959",
        "source-f31f86bc84bd28d7"
      ],
      "sourceLocators": [
        {
          "sourceId": "source-1bffcf35253de959",
          "locator": "What is a smart contract; a digital vending machine; limitations; multisig"
        },
        {
          "sourceId": "source-f31f86bc84bd28d7",
          "locator": "State transition function; EVM instructions; storage"
        }
      ],
      "scope": {
        "collection": "ethereum",
        "dataAsOf": null,
        "blockHeight": null
      },
      "qualification": "",
      "evidenceStatus": "documented",
      "verification": {
        "status": "verified",
        "method": "independent automated source review",
        "checkedAt": "2026-10-02T18:16:35.976Z",
        "reviewer": "Codex independent automated reviewer /root/verify_ethereum_100",
        "notes": [
          "Checked eth_call state/input semantics and EIP-140 failure, rollback and remaining-gas rules against EIP-658 top-level receipt status.",
          "Added eth-gas and Solidity Message Calls support for consumed-gas charges and a handled nested failure coexisting with overall success. No later-inclusion guarantee is given."
        ]
      }
    },
    {
      "id": "ethereum-smart-contracts-fact-components",
      "articleSlug": "ethereum-smart-contracts",
      "statement": "Components: Code plus persistent state",
      "sourceIds": [
        "source-1bffcf35253de959"
      ],
      "sourceLocators": [
        {
          "sourceId": "source-1bffcf35253de959",
          "locator": "What is a smart contract; a digital vending machine; limitations; multisig"
        }
      ],
      "scope": {
        "collection": "ethereum",
        "dataAsOf": null,
        "blockHeight": null
      },
      "qualification": "",
      "evidenceStatus": "documented",
      "verification": {
        "status": "verified",
        "method": "independent automated source review",
        "checkedAt": "2026-10-02T18:16:35.976Z",
        "reviewer": "Codex independent automated reviewer /root/verify_ethereum_100",
        "notes": [
          "Checked eth_call state/input semantics and EIP-140 failure, rollback and remaining-gas rules against EIP-658 top-level receipt status.",
          "Added eth-gas and Solidity Message Calls support for consumed-gas charges and a handled nested failure coexisting with overall success. No later-inclusion guarantee is given."
        ]
      }
    },
    {
      "id": "ethereum-smart-contracts-fact-invocation",
      "articleSlug": "ethereum-smart-contracts",
      "statement": "Invocation: Transactions or calls trigger execution",
      "sourceIds": [
        "source-b75ec7ad726d1661",
        "source-1bffcf35253de959"
      ],
      "sourceLocators": [
        {
          "sourceId": "source-b75ec7ad726d1661",
          "locator": "What is a transaction; the data field; transaction lifecycle"
        },
        {
          "sourceId": "source-1bffcf35253de959",
          "locator": "What is a smart contract; a digital vending machine; limitations; multisig"
        }
      ],
      "scope": {
        "collection": "ethereum",
        "dataAsOf": null,
        "blockHeight": null
      },
      "qualification": "",
      "evidenceStatus": "documented",
      "verification": {
        "status": "verified",
        "method": "independent automated source review",
        "checkedAt": "2026-10-02T18:16:35.976Z",
        "reviewer": "Codex independent automated reviewer /root/verify_ethereum_100",
        "notes": [
          "Checked eth_call state/input semantics and EIP-140 failure, rollback and remaining-gas rules against EIP-658 top-level receipt status.",
          "Added eth-gas and Solidity Message Calls support for consumed-gas charges and a handled nested failure coexisting with overall success. No later-inclusion guarantee is given."
        ]
      }
    },
    {
      "id": "ethereum-smart-contracts-fact-outside-information",
      "articleSlug": "ethereum-smart-contracts",
      "statement": "Outside information: Needs an external input mechanism such as an oracle",
      "sourceIds": [
        "source-1bffcf35253de959"
      ],
      "sourceLocators": [
        {
          "sourceId": "source-1bffcf35253de959",
          "locator": "What is a smart contract; a digital vending machine; limitations; multisig"
        }
      ],
      "scope": {
        "collection": "ethereum",
        "dataAsOf": null,
        "blockHeight": null
      },
      "qualification": "",
      "evidenceStatus": "documented",
      "verification": {
        "status": "verified",
        "method": "independent automated source review",
        "checkedAt": "2026-10-02T18:16:35.976Z",
        "reviewer": "Codex independent automated reviewer /root/verify_ethereum_100",
        "notes": [
          "Checked eth_call state/input semantics and EIP-140 failure, rollback and remaining-gas rules against EIP-658 top-level receipt status.",
          "Added eth-gas and Solidity Message Calls support for consumed-gas charges and a handled nested failure coexisting with overall success. No later-inclusion guarantee is given."
        ]
      }
    }
  ],
  "sources": [
    {
      "id": "contracts",
      "label": "Introduction to smart contracts",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/smart-contracts/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/smart-contracts/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:40.398357+00:00",
      "locator": "What is a smart contract; a digital vending machine; limitations; multisig",
      "sha256": "e0933f91c6c58d30c1f5f05cac3c45529bf34dcb0711bbaa9a4dfe2b9b9946db",
      "note": "Supports contract code/state, deterministic rules, illustrative vending logic, external-data limits and multisignature access.",
      "recordId": "source-1bffcf35253de959",
      "contentSha256": "e0933f91c6c58d30c1f5f05cac3c45529bf34dcb0711bbaa9a4dfe2b9b9946db"
    },
    {
      "id": "evm",
      "label": "Ethereum Virtual Machine",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/evm/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/evm/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:40.399163+00:00",
      "locator": "State transition function; EVM instructions; storage",
      "sha256": "2a938eb38a613c0cd2e27229691f7bc3741585ab495a89e9db67fdd575f8b052",
      "note": "Supports deterministic execution, opcodes and the distinction between temporary execution memory and persistent state.",
      "recordId": "source-f31f86bc84bd28d7",
      "contentSha256": "2a938eb38a613c0cd2e27229691f7bc3741585ab495a89e9db67fdd575f8b052"
    },
    {
      "id": "transactions",
      "label": "Ethereum transactions",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/transactions/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/transactions/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:40.399251+00:00",
      "locator": "What is a transaction; the data field; transaction lifecycle",
      "sha256": "59345c5f1ceb028a1e16e21c5fd22e902b5714c94a7d9be349f2d100422880ab",
      "note": "Supports nonce ordering, value versus calldata, signed transaction fields, receipts and transaction inclusion.",
      "recordId": "source-b75ec7ad726d1661",
      "contentSha256": "59345c5f1ceb028a1e16e21c5fd22e902b5714c94a7d9be349f2d100422880ab"
    },
    {
      "id": "accounts",
      "label": "Ethereum accounts",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/accounts/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/accounts/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:40.369782+00:00",
      "locator": "Account types; an account examined; a note on wallets",
      "sha256": "774839a895f46d6d398c27ab56e3a3ba9eb445eae87374cf41a78e7f28ac7983",
      "note": "Supports accounts versus wallet software and account state fields. The older empty-code EOA description is qualified using EIP-7702.",
      "recordId": "source-d131f5d8edf3944c",
      "contentSha256": "774839a895f46d6d398c27ab56e3a3ba9eb445eae87374cf41a78e7f28ac7983"
    },
    {
      "id": "interacting",
      "label": "Interacting with smart contracts",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/smart-contracts/interacting/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/smart-contracts/interacting/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:40.398262+00:00",
      "locator": "Reading; writing; understanding contract ABIs; events and logs; simulating",
      "sha256": "0c969a8627399edfcae7e30d5fa1fcc02218265808be25f52a9a9a46da7dc29f",
      "note": "Supports read-only calls, state-changing transactions, ABI decoding and limits of simulation.",
      "recordId": "source-64ab603c23f79017",
      "contentSha256": "0c969a8627399edfcae7e30d5fa1fcc02218265808be25f52a9a9a46da7dc29f"
    },
    {
      "id": "upgrading",
      "label": "Upgrading smart contracts",
      "publisher": "ethereum.org contributors",
      "url": "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dcc900ff125891da5b6c723b905a7113cf1bd864/public/content/developers/docs/smart-contracts/upgrading/index.md",
      "canonicalUrl": "https://ethereum.org/en/developers/docs/smart-contracts/upgrading/",
      "version": "dcc900ff125891da5b6c723b905a7113cf1bd864",
      "checkedAt": "2026-10-02T14:35:43.712296+00:00",
      "locator": "What is a smart contract upgrade; proxy patterns; limitations",
      "sha256": "c1314b02587c77a7b43ce0ba02b5c8945f57b4f55ce142adb2e76044243556e5",
      "note": "Supports separation of deployed code from changeable application behavior and upgrade authority.",
      "recordId": "source-3c467cd6c5e31729",
      "contentSha256": "c1314b02587c77a7b43ce0ba02b5c8945f57b4f55ce142adb2e76044243556e5"
    },
    {
      "id": "edition-eth-jsonrpc",
      "label": "Ethereum JSON-RPC",
      "publisher": "ethereum.org contributors",
      "url": "https://ethereum.org/en/developers/docs/apis/json-rpc/",
      "locator": "eth_getTransactionByHash; eth_getTransactionReceipt; eth_call; eth_getLogs; eth_getCode; eth_estimateGas; eth_getBalance; eth_getStorageAt; eth_getTransactionCount; default block parameter",
      "note": "RPC response fields, transaction receipts, call simulation and log filtering.",
      "version": null,
      "checkedAt": "2026-10-02T17:03:42.060Z",
      "contentSha256": "ed13997ec4f415dff80883add0730d4e64bcc8c17b95dd4f6c27aed0241a4073",
      "recordId": "source-a5154b4118a3d15f"
    },
    {
      "id": "edition-eip140",
      "label": "REVERT instruction",
      "publisher": "Ethereum Improvement Proposals",
      "url": "https://eips.ethereum.org/EIPS/eip-140",
      "locator": "Specification",
      "note": "State rollback and remaining gas behavior for a REVERT instruction.",
      "version": "EIP/ERC-140; retrieved document hash recorded",
      "checkedAt": "2026-10-02T17:03:42.150Z",
      "contentSha256": "e6f49a3606194ec36158182489ede14ccc81b5d44b2450ea15f40d568e912345",
      "recordId": "source-ccab9c4be966af8f"
    },
    {
      "id": "edition-eip658",
      "label": "Embedding transaction status code in receipts",
      "publisher": "Ethereum Improvement Proposals",
      "url": "https://eips.ethereum.org/EIPS/eip-658",
      "locator": "Specification",
      "note": "Receipts report top-level execution success or failure.",
      "version": "EIP/ERC-658; retrieved document hash recorded",
      "checkedAt": "2026-10-02T17:03:42.150Z",
      "contentSha256": "8bd00dd00fb9ce4944ba96e0c986486d90df7bd78c88ff9f9b6a7c7a56287f58",
      "recordId": "source-fc3b7cce0edd664b"
    },
    {
      "id": "edition-eth-gas",
      "label": "Gas and fees",
      "publisher": "ethereum.org contributors",
      "url": "https://ethereum.org/en/developers/docs/gas/",
      "locator": "What is gas?; Base fee; Priority fee",
      "note": "Execution resource units, fee components and gas expenditure.",
      "version": null,
      "checkedAt": "2026-10-02T17:03:41.688Z",
      "contentSha256": "566e61b7dce594a477ef28bab1f5a23279feb4f782e2838623fc7491c9daec66",
      "recordId": "source-5cadd0da692ffaa8"
    },
    {
      "id": "edition-solidity-delegatecall",
      "label": "Solidity: Delegatecall and Libraries",
      "publisher": "Solidity contributors",
      "url": "https://docs.soliditylang.org/en/v0.8.30/introduction-to-smart-contracts.html",
      "locator": "Delegatecall and Libraries; Storage, Memory and the Stack; Logs; Message Calls",
      "note": "Execution uses another contract’s code in the caller’s context and storage.",
      "version": "Solidity 0.8.30 documentation",
      "checkedAt": "2026-10-02T17:03:42.822Z",
      "contentSha256": "9fde27b9eb16bcd47d5e9fb73a80d2d3b288ae7b74ac56b29956267028fe7a55",
      "recordId": "source-7399ee01181109d4"
    }
  ],
  "related": {
    "articles": [
      "ethereum-virtual-machine",
      "ethereum-wallet-requests",
      "ethereum-smart-accounts"
    ],
    "dossiers": [],
    "wallets": []
  },
  "revisionHistory": [
    {
      "date": "2026-10-02",
      "kind": "published",
      "summary": "First publication after primary-source research and independent automated verification."
    },
    {
      "date": "2026-10-02",
      "kind": "substantive-edit",
      "summary": "Expanded explanation: A preview and an included failed call have different effects. Worked examples are illustrative; source checks and independent verification are recorded separately."
    }
  ],
  "citation": "Degrees of Satoshi editorial project. “Smart contracts: programmed rules, examples and outside promises.” Published 2026-10-02; updated 2026-10-02. https://degreesofsatoshi.com/encyclopedia/ethereum-smart-contracts/"
}
