Bitfolio
TechExplainer

Smart contracts and the law: does code replace a contract, and who answers when it fails?

Developers sometimes say code is law. Regulators and courts have answered that code sits inside the law, and the answer depends on what the program does and who controls it.

Lines of programming code on a computer screen, seen at an angle
Photo: “Programmers Reflection on Screen Showing Code” by qubodup, CC BY 2.0, via flickr.com · Edited: duotone, cropped.

The short answer

A smart contract is a program that runs exactly as written, but being code does not put it outside the law. The SEC treated The DAO's tokens as securities, US agencies apply financial rules to DeFi by function, and a 2024 appeals ruling limited sanctions on immutable code.

Key takeaways

  1. A smart contract is code and data at a blockchain address; by default it cannot be deleted and interactions with it are final.
  2. In 2017 the SEC concluded that tokens sold by The DAO, an organisation run by code, were securities.
  3. The Treasury says a DeFi service that functions as a financial institution must meet anti-money-laundering rules whatever its structure.
  4. In 2024 a federal appeals court held that Tornado Cash's immutable smart contracts were not property that sanctions could block.
  5. Whether a program creates obligations a court will enforce depends on the governing law; the US sources used here do not declare code automatically binding.

What did The DAO teach regulators about code?

The DAO was an organisation embodied in computer code and run on a blockchain3. In 2016 it sold roughly 1.15 billion DAO tokens for about 12 million ETH3. In June an unknown attacker began draining funds and moved about 3.6 million ETH, a third of the total raised, to an address under their control3. The Ethereum community changed the network's rules with a hard fork that took effect on 20 July 2016 and sent the funds to a recovery address34.

The SEC's July 2017 report then concluded that DAO tokens were securities3. Automation did not change the legal character of what investors bought. Our Howey test explainer covers how US law decides whether something is an investment contract.

Note

The code worked, the outcome was reversed

The attacker exploited the contract's code, yet the funds were later moved by a change to the network's rules34. Both the exploit and the fix came from human choices around the code.

Can a smart contract be sanctioned?

The Tornado Cash case tested that question. Treasury sanctioned the Ethereum mixer in August 20226. On 26 November 2024 the Fifth Circuit held in Van Loon v. Department of the Treasury that Tornado Cash's immutable smart contracts are not property under the sanctions statute and so cannot be blocked7. The court did not decide whether Tornado Cash is an entity, and it did not rule on contracts that can be changed7.

Treasury removed Tornado Cash from the sanctions list on 21 March 2025, citing the novel legal and policy issues of sanctioning evolving technology, while stressing continued concern about North Korean laundering8. Separately, on 6 August 2025 a federal jury convicted a co-founder of conspiracy to operate an unlicensed money transmitting business9. Code may escape one statute and the people around it still face another. See sanctions and crypto for the wider rules.

Figure · Tornado Cash in the courts and at Treasury

Tornado Cash in the courts and at TreasuryAug 2022SanctionedNov 2024Appeals rulingMar 2025Removed from listAug 2025Conviction
  1. Aug 2022Sanctioned
  2. Nov 2024Appeals ruling
  3. Mar 2025Removed from list
  4. Aug 2025Conviction

Who is responsible when a DeFi contract is involved?

Regulators look past the word "decentralised". IOSCO's 2023 policy recommendations note that DeFi arrangements often still have people who control or strongly influence them10. The US Treasury says a DeFi service that functions as a financial institution under the Bank Secrecy Act must meet anti-money-laundering obligations whatever it calls itself11.

For a user, that means the legal question is rarely about the contract alone. It is about who wrote it, who can upgrade or pause it, and who earns from it. Contracts designed with upgrade or pause functions give someone power over them2, and that power is exactly what supervisors try to locate.

What happens to your money when code fails?

Because interactions are final by default1, a bug or exploit usually cannot be undone by the contract itself. ethereum.org estimates that value stolen or lost through smart contract flaws is easily over $1 billion, and says audits will not catch every bug2. Legal remedies, if any, run against people and firms, not against the code.

Risk warning

No regulator stands behind the code

Before sending funds to a contract, find out who can change it, who runs the service around it and what recourse, if any, exists if it fails. Assume a loss may be permanent.

What mistakes do people make about smart contracts and the law?

Common beginner mistakes

  1. Believing code is beyond regulation

    The SEC's DAO report and Treasury's DeFi assessment both apply existing law to code-based activity311.

  2. Reading the Tornado Cash ruling broadly

    The court addressed immutable contracts under one sanctions statute; it did not decide mutable contracts7.

  3. Assuming nobody is in charge

    IOSCO found that DeFi often has responsible persons behind it10.

  4. Expecting a reversal after a loss

    Contract interactions are irreversible by default1.

For how contracts are written, deployed and executed on-chain, go deeper on Protocol Insights: what is a smart contract.

Frequently asked questions

Is a smart contract legally binding?

Not automatically. A program can carry out an agreement, but whether it creates obligations a court will enforce depends on the governing law. The US sources here focus on how securities, sanctions and anti-money-laundering rules apply311.

Can a token created by a smart contract be a security?

Yes. The SEC concluded in 2017 that The DAO's tokens were securities3; see our token standards page for how tokens are built.

Did the Tornado Cash ruling legalise mixers?

No. It held that immutable smart contracts were not blockable property under one statute7, and a co-founder was still convicted on a money-transmitting charge9.

Who can I pursue if a DeFi contract loses my funds?

Remedies run against people or firms, and IOSCO notes DeFi often has responsible persons10. Recovery is never guaranteed.

The bottom line

Smart contracts execute without asking permission, but they do not execute outside the law. The SEC treated code-issued tokens as securities, Treasury applies anti-money-laundering rules to DeFi by function, and a federal appeals court drew a narrow line around immutable code. Before relying on a contract, ask who controls it and which legal rules still reach the people behind it. For a related scaling topic, see who controls a layer 2 rollup.

Sources

  1. Introduction to smart contracts — ethereum.org developer documentation Primary source
  2. Smart contract security — ethereum.org developer documentation Primary source
  3. Report of Investigation Pursuant to Section 21(a) of the Securities Exchange Act of 1934: The DAO (Release No. 81207) — U.S. Securities and Exchange Commission, 2017 Primary source
  4. The history of Ethereum (network upgrades) — ethereum.org Primary source
  5. A Primer on Smart Contracts — LabCFTC, U.S. Commodity Futures Trading Commission, 2018 Primary source
  6. U.S. Treasury Sanctions Notorious Virtual Currency Mixer Tornado Cash (jy0916) — U.S. Department of the Treasury, 2022 Primary source
  7. Van Loon v. Department of the Treasury, No. 23-50669 (5th Cir. 2024) — U.S. Court of Appeals for the Fifth Circuit, 2024 Primary source
  8. Tornado Cash Delisting (sb0057) — U.S. Department of the Treasury, 2025 Primary source
  9. Press release on the jury verdict against Tornado Cash co-founder Roman Storm (6 August 2025) — U.S. Attorney's Office, Southern District of New York, 2025 Primary source
  10. Final Report with Policy Recommendations for Decentralized Finance (DeFi) — International Organization of Securities Commissions (IOSCO), 2023 Primary source
  11. Illicit Finance Risk Assessment of Decentralized Finance — U.S. Department of the Treasury, 2023 Primary source

How we checked this page: every figure above links to the numbered source it came from. Spotted an error? Tell the desk — see our editorial policy.