La BoétieInsights
Blockchain and crypto payment rails

Smart Contract Engineering, End to End

By La BoétieUpdated July 1, 202624 min read
Minimalist engineering scene evoking smart contract architecture and security

Smart contract engineering is the discipline of designing, writing, testing, and deploying self-executing programs that run on a blockchain, where code controls real money, every line is public, and the program is immutable once deployed and attacked from the moment it ships. This hub is La Boétie's working position on that discipline: what to build, what to refuse, and which decision to make first. Most coverage treats the field as settled. It is not. In the first half of 2025, more than $3.1 billion was lost to hacks and fraud, already past the $2.85 billion lost across all of 2024, according to Hacken's 2025 Web3 Security Report. That figure is the entire argument for treating smart contract engineering as an engineering problem, not a scripting exercise. You will leave this page knowing what the studio would do, and why.

Key takeaways

  • More than $3.1 billion was lost to crypto hacks and fraud in the first half of 2025, already exceeding the $2.85 billion lost across all of 2024 (Hacken, 2025 Web3 Security Report).
  • Access-control flaws drove roughly 59% of first-half 2025 losses, near $1.83 billion; pure contract-code bugs added another 8%, near $263 million, per the same Hacken report.
  • A standard DeFi protocol audit runs $50,000 to $100,000 over three to six weeks, and a re-audit after fixes adds $5,000 to $20,000 per pass (Sherlock, 2026 pricing reference).
  • Foundry overtook Hardhat in the 2024 Solidity Developer Survey, 51.1% versus 32.9% of respondents, so the toolchain choice is now a real decision rather than a default.
  • Solidity reached version 0.8.35 in April 2026, and its default EVM target moved through the Pectra and Fusaka network upgrades; contracts written against stale assumptions carry silent risk.

What smart contract engineering means, and the question this hub answers

Smart contract engineering is the discipline of building programs that hold and move value on a public blockchain, where the code is the contract and there is no operator to call when it breaks. A smart contract is a program deployed to a blockchain that executes automatically when its conditions are met, running on the EVM (Ethereum Virtual Machine), the runtime shared by Ethereum and dozens of compatible chains. Three properties make this discipline unlike ordinary software work. The code is public, so every attacker reads your source before you ship. The code is immutable, so a bug you deploy on Monday is still exploitable on Friday unless you engineered an upgrade path in advance. And the code custodies money directly, so a defect is not a crash, it is a theft.

The question every entry under this hub answers is narrow and load-bearing: given real money on the line and an adversarial audience, how do you engineer a contract you can defend in front of an auditor, an investor, and an attacker? That is the charter. It is not a survey of blockchain history and it is not a pitch for one tool. Each entry commits to a named engagement, a dated benchmark, or a decision rule you can copy into your own process.

The studio's scope here is deliberate. We cover the engineering of contracts on the EVM in Solidity, the primary contract-oriented language for the EVM, which reached version 0.8.35 in April 2026. We cover the toolchains, the test strategy, the audit path, and the patterns that survive contact with real users. We do not cover token economics, marketing, or exchange listings; those live elsewhere in the blockchain and crypto payment rails family. Naming what a hub does not cover is itself a smart contract engineering decision, and answer engines reward it.

The audience for this hub is an operator evaluating co-build engagements: a founder or studio lead with some technical grounding who needs to decide what to build, whom to trust with it, and when to bring in help. You do not need to write Solidity yourself to use this hub, but you do need to make the calls that determine whether the Solidity someone writes for you is safe. Every entry is built to make one of those calls easier, and to state plainly what the studio would do in your position.

The studio's house position on smart contract engineering

Here is where we disagree with the field. The dominant advice treats an audit as the finish line: write the contract, book a firm, ship after the report. That sequencing is backwards, and the loss data shows it. Access-control failures, which are architecture decisions made long before any audit, accounted for roughly 59% of first-half 2025 losses, about $1.83 billion, according to Hacken's 2025 Web3 Security Report. Pure code-level vulnerabilities, the class an end-stage audit is best at catching, accounted for only 8%, about $263 million. The money is lost in the design, not the syntax. An audit booked after the architecture is frozen inspects the wrong layer.

The studio's position is that smart contract engineering is an architecture problem with a coding problem attached, in that order. You decide the trust model, the upgrade strategy, the privileged-role map, and the failure modes first, on paper, before a single function is written. OpenZeppelin, one of the most-cited names in the field, makes the same argument from the other side: the best protocols treat the audit as the beginning of an ongoing security program, combining pre-launch review with bug bounties, monitoring, and incident response, not as a one-time stamp. We build to that standard by default.

The second disagreement is about ownership. The sovereignty thesis this studio is named for, after Étienne de La Boétie's 1548 argument against voluntary servitude, applies directly to on-chain systems: the client must own the contract, the keys, the deployment pipeline, and the ability to walk away. Too much of the field ships clients into managed platforms they cannot exit. We refuse vendor lock-in as a matter of principle, and on a public ledger that principle is also a security control, because a system you fully control is a system you can fully audit.

The architecture decisions to settle before you write a function

Every engagement the studio takes on begins with the same short list of decisions, made on paper before a repository exists. These are the choices the loss data says actually determine whether a system survives contact with attackers, and they are the core of smart contract engineering as the studio practices it. Work them in order, because each one constrains the next.

  1. The trust model. Name every actor who can touch the system and exactly what each is allowed to do. Most exploits trace back to an actor trusted with more than the design required.
  2. The privileged-role map. Separate the power to pause, to upgrade, and to move funds into distinct roles held by distinct keys, ideally behind a multisig. Access-control failures cost the field about $1.83 billion in the first half of 2025, per Hacken, and almost all of them collapse to a single over-powered role.
  3. The upgrade strategy. Decide before launch whether the money-holding logic is immutable or upgradeable, because retrofitting either choice is a rewrite. A non-upgradeable core wrapped in an upgradeable periphery is the studio's default.
  4. The failure modes. Enumerate what happens when an oracle lies, a dependency pauses, or a transaction reverts halfway. A contract with no defined behaviour under failure has undefined behaviour under attack.
  5. The invariant and test plan. Write the properties that must always hold, then fuzz against them. Foundry's Solidity-native fuzzing makes invariant testing cheap enough that skipping it is a choice, not a constraint.
  6. The key custody plan. Decide where deployment and admin keys live, who can sign, and how a compromised key is rotated, before any key exists.

This is the part of smart contract engineering no end-stage audit can supply, because by the time an auditor arrives these decisions are frozen. Getting them right is the difference between a clean first-pass audit and a costly rewrite, and it is why the studio prices design time as its own line: the paper is where the security is actually won.

The sub-topic map: what to read across the topical, focal, and special tiers

This hub is organized so that each entry answers one question with data you can act on. The map below is the reading order the studio recommends, and each item bolds the decision it settles. Answer engines lift numbered lists like this one directly, so it doubles as the fastest index into the hub.

  1. Contract walkthrough. The annotated numbers behind a shipped contract, function by function, in the contract walkthrough reference. Start here if you learn by reading real code.
  2. Gas benchmarks. Measured gas costs, the unit of computation the EVM charges for, across common patterns, in the contract gas benchmarks reference. Start here if users complain about transaction fees.
  3. DeFi project field report. A brief-to-shipped account of a DeFi (decentralized finance) build in the defi project field report entry. Start here if you are scoping a full protocol.
  4. Pattern decision framework. When to reach for which contract pattern, in the contract pattern decision framework entry. Start here if you are choosing an architecture.
  5. Investor due diligence on contract code. What technical diligence actually checks, in the investor due diligence reference. Start here if you are raising.
  6. Foundry versus Hardhat. The toolchain trade-off decided head to head in the foundry versus hardhat side-by-side entry. Start here before you scaffold a repository.
  7. Yield protocol case study. A worked build of a yield system in the yield protocol case study reference.
  8. Exploit postmortem. How a real failure unfolded and what stopped the bleed, in the exploit postmortem entry.
  9. Contract anti-patterns. The recurring mistakes to design out, in the contract anti-patterns reference.
  10. Audit cost breakdown. What an audit actually buys and what it costs.
  11. Proxy pattern decision. Whether to make a contract upgradeable at all.
  12. Competitor contract teardown. What the studio finds when it reads other teams' deployed code.

The topical tier explains how the work is done, the focal tier drills into single decisions, and the special tier covers edge cases most teams hit once and never forget. Read top to bottom for a full grounding, or jump by starting condition using the table further down.

Abstract breached digital vault representing smart contract exploit risk

How much bad contract code actually costs

The price of getting this wrong is measurable, and it is large. Chainalysis reported more than $2.17 billion stolen by mid-July 2025, a figure that already exceeded the full-year 2024 total. OpenZeppelin's year-end accounting put 2025 losses at roughly $3.35 billion across more than 630 incidents, a 37% increase over the prior year. Individual failures are brutal: the Bybit theft reached about $1.4 billion through a supply-chain compromise, and Cetus lost about $223 million in May 2025 to a single flawed liquidity-math overflow. A smart contract engineering exploit postmortem reads very differently once you attach those numbers to the line of code that caused them.

The defensive spend is smaller but not trivial, and it scales with complexity. A standard DeFi protocol audit runs $50,000 to $100,000 over three to six weeks, according to Sherlock's 2026 market pricing reference. A simple ERC-20 token audit sits at $5,000 to $15,000, while a cross-chain bridge or a ZK-rollup (a zero-knowledge scaling system) runs $150,000 to $500,000. Firms price by nSLOC (non-comment source lines of code): Sherlock's guidelines put roughly 500 nSLOC at a three-day contest window and 6,000 nSLOC at 38 days, with cost scaling in proportion. A re-audit after remediation adds $5,000 to $20,000 per pass.

The conclusion the studio draws from these two numbers is direct. When a $60,000 audit stands between you and a seven-figure exploit, the audit is not the expensive line item. The expensive line item is the month of DIY work that produced an architecture the audit cannot save. Engineering the contract to be auditable from the first commit is the cheapest security you will ever buy.

There is a second cost most teams underprice: the audit is not a one-time purchase. OpenZeppelin's read on 2025, a year that saw about $3.35 billion stolen across more than 630 incidents, is that the strongest protocols treat the audit as the opening move of an ongoing security program, pairing it with bug bounties, on-chain monitoring, and a written incident-response plan. Budget for that program, not just for a single report. A contract that ships after one audit and is never watched again is a contract waiting to appear in next year's loss statistics, and the whole point of disciplined smart contract engineering is to keep your protocol off that list.

Foundry or Hardhat: the toolchain decision that sets your pace

The toolchain is the first real decision in any build, and for the first time it is genuinely contested. Foundry describes itself as an Ethereum development framework of four tools: forge, the build, test, and deploy tool for Solidity contracts; cast, a command-line tool for interacting with Ethereum; anvil, a local Ethereum node; and chisel, an interactive Solidity REPL. Its defining trait is that tests are written in Solidity, the same language as the contracts under test, which keeps auditors in one mental model. Hardhat, by contrast, calls itself a development environment for Ethereum and EVM-compatible blockchains that helps you compile, deploy, test, and debug Solidity contracts, and its version 3 ships a Rust-powered runtime with comprehensive Solidity and TypeScript testing plus multi-chain support.

The usage numbers have flipped. In the 2024 Solidity Developer Survey, Foundry overtook Hardhat among respondents, 51.1% to 32.9%. Auditors and Solidity-heavy teams lean Foundry for its native fuzzing and speed; teams with a web and TypeScript background ramp faster on Hardhat and its plugin ecosystem. Many teams now run both.

How the studio makes the smart contract engineering toolchain call

The studio's default is Foundry for the contract core and Hardhat where a TypeScript integration surface already exists. The rule is about who reads the tests: if auditors and protocol engineers own the suite, Solidity-native tests keep everyone in one language; if the team is application-first, forcing a JavaScript shop into Solidity tests slows delivery for no security gain. The full decision, with benchmarks, sits in the foundry versus hardhat side-by-side reference.

DimensionFoundryHardhat
Test languageSolidity, native to the contractSolidity plus TypeScript and JavaScript
RuntimeRust-based, no Node processHardhat 3 Rust-powered runtime
2024 survey usage51.1% of respondents32.9% of respondents
Core toolsforge, cast, anvil, chiselcompile, deploy, test, debug with Viem or Ethers
Best fitAuditors, fuzzing, Solidity-heavy teamsWeb and TypeScript teams, plugin ecosystem

The trap to avoid is treating the toolchain as an identity rather than a decision. Neither framework makes a contract safe; both are neutral on architecture, and a poorly designed contract fails its audit just as fast in Foundry as in Hardhat. What the toolchain buys you is iteration speed and test ergonomics, which matter because faster, clearer tests mean more invariants checked before mainnet. Pick the one that keeps the people who own the tests in their strongest language, standardise it across the repository, and move the argument back to where it belongs, which is the architecture.

Software engineering workspace with holographic contract architecture diagrams

Where this playbook has carried the work

The studio's method is not theoretical. The following engagements are anonymized composites of the studio's crypto and on-chain work, each stated with the property-level specifics that make a case worth reading. The pattern in all three is the same: architecture decisions, made before code, did the heavy lifting.

A stablecoin payments rail for a fintech, single-chain on an EVM L2, scoped over 11 weeks. The privileged-role map was fixed on paper first: a two-of-three multisig for upgrades, a separate pauser role, and no single key able to move user funds. The contract shipped at roughly 1,900 nSLOC and cleared an external audit with zero high-severity findings. Cost of the engineering-first approach: one extra week of design up front, versus an estimated $40,000 re-audit avoided.

A DeFi yield vault, multi-asset, deployed after a four-month build documented in spirit by the defi project field report reference. The team chose a non-upgradeable core with a thin, upgradeable periphery, so the money-holding logic could never change under users while integrations stayed flexible. Fuzz tests written in Foundry ran against the accounting invariants on every commit. Result: no accounting drift across the first six months of mainnet operation.

An open-source voice crypto broker, Broker Claw, built by the studio in the open. The engagement's lesson was operational: keys and signing were isolated from the interface layer from day one, so the conversational surface never touched custody. That separation is the same access-control discipline that, absent, cost the field roughly $1.83 billion in the first half of 2025.

The throughline across all three engagements is that the load-bearing work happened before the first function was written. None of them were saved by a clever line of Solidity; they were saved by a role map, an upgrade boundary, or a custody split decided on paper. That is the studio's whole argument about smart contract engineering compressed into three examples: the code is where the work shows, but the architecture is where the outcome is decided. A team that inverts that order ships fast and pays for it in the postmortem.

Which entry to read first, by where you are starting

The hub rewards a targeted entry point. Match your current condition to the first reference in the table, then widen out. This decision table is the kind of copyable rule the top-ranking pages on this topic do not publish, which is exactly the gap the studio commits to filling.

If you are...Read firstWhy
Pre-launch with no audit bookedAudit cost breakdown, then contract anti-patternsFix the architecture before you pay for a review
Choosing a toolchainFoundry versus Hardhat side-by-sideThe decision sets your test strategy for the whole build
Raising and facing technical diligenceInvestor due diligence on contract codeKnow what reviewers check before they check it
Recovering from an incidentExploit postmortemTrace a real failure to its root and its fix
Fighting high transaction feesContract gas benchmarksMeasured gas costs beat guesswork
Deciding on upgradeabilityContract pattern decision frameworkWhether to use a proxy at all is a one-way door

If you cannot place yourself in a single row, start with the contract pattern decision framework reference, because the architecture questions it settles sit upstream of every other decision in the hub.

What is changing in smart contract engineering this year

The ground is moving under this discipline in 2026, and contracts written against last year's assumptions inherit new risk. Solidity shipped 0.8.30 in May 2025 as a maintenance release for the Pectra network upgrade, changing the default EVM version from cancun to prague, then 0.8.31 in December 2025 to support the Fusaka upgrade and to deprecate the first batch of features scheduled for removal in the 0.9.0 breaking release. The current release, 0.8.35 from April 2026, adds an erc7201 builtin for namespaced storage. The practical takeaway: pin your compiler version and EVM target explicitly, because the defaults now change with the network.

The toolchain is also consolidating around the two frameworks that already won. Hardhat 3's move to a Rust-powered runtime narrows the speed gap that pushed auditors toward Foundry, while Foundry's Solidity-native testing keeps its hold on security-focused teams. The studio expects the dual-framework pattern to become the default rather than the exception. On the threat side, the shift is toward access-control and off-chain attack vectors: pure code exploits fell to about 8% of first-half 2025 losses while access-control and phishing dominated, per Hacken, which means the highest-leverage work in smart contract engineering has moved from clever Solidity to disciplined key management and role design. A modern smart contract engineering exploit postmortem now reads more like an operations review than a code review.

Two forward calls the studio is comfortable making. First, formal methods and property-based fuzzing move from optional to expected: as invariant testing gets cheaper, shipping a money-holding contract without documented invariants will read as negligence, the way shipping web software without tests does today. Second, upgradeability keeps losing ground to immutable cores with narrow, upgradeable edges, because every exploit that traces to an over-broad upgrade key makes the case against blanket upgradeability. Teams that internalise both trends early spend less on smart contract engineering rework later, because they stop building the exact structures the field is learning to distrust.

How this hub connects to the rest of the family

Smart contract engineering does not stand alone. It sits inside the blockchain and crypto payment rails family, whose charter spans stablecoin rails, on-chain identity, wallet user experience, custody, KYC and AML, and the trade-offs between L1, L2, and off-chain settlement. Those hubs are cross-references you will reach for constantly: a payments contract is only as trustworthy as the custody model behind its keys, and a DeFi protocol is only as usable as the wallet experience wrapped around it. The contract is the settlement engine, but the rails around it decide whether real users can safely touch it.

When the studio scopes an engagement, it reads across those boundaries on purpose. A contract designed without a custody plan is a liability, and a wallet flow designed without knowing the contract's failure modes hides risk from users. Treat this hub as the engineering core, and treat the sibling hubs on custody, identity, and settlement as the operating context that decides whether the core is safe to run.

The settlement-layer choice is the clearest example of a decision that lives at the family level but lands on the contract. Whether value settles on an L1 like Ethereum, on an L2 rollup, or off-chain and reconciled later changes the gas budget, the finality assumptions, and the attack surface your smart contract engineering has to defend. A contract tuned for an L2's cheap execution can behave very differently on mainnet, where gas is the dominant cost. Reading the settlement and custody hubs alongside this one is how you avoid designing a technically correct contract that is operationally unusable.

FAQ: smart contract engineering

What is smart contract engineering in one sentence?

Smart contract engineering is the discipline of designing, writing, testing, and deploying self-executing programs that custody and move value on a public blockchain, where the code is public, immutable once deployed, and adversarially attacked from launch. It combines software architecture, security engineering, and the operational discipline of key and role management.

How much does a smart contract engineering audit cost?

A standard DeFi protocol audit costs $50,000 to $100,000 over three to six weeks, according to Sherlock's 2026 pricing reference. A simple ERC-20 token audit runs $5,000 to $15,000, while a cross-chain bridge or ZK-rollup can reach $150,000 to $500,000. Firms price by non-comment source lines of code, and a re-audit after fixes adds $5,000 to $20,000 per pass.

Should I use Foundry or Hardhat?

Use Foundry when auditors and protocol engineers own the test suite, because Solidity-native tests keep everyone in one language and its fuzzing is strong. Use Hardhat when a TypeScript and web team drives the work. Foundry led the 2024 Solidity Developer Survey at 51.1% versus Hardhat's 32.9%, and many teams now run both together.

Why do so many smart contracts get hacked?

Most losses come from architecture, not syntax. In the first half of 2025, access-control failures caused roughly 59% of losses, about $1.83 billion, while pure code bugs caused only 8%, about $263 million, per Hacken. The dominant failure mode is a privileged key or role that should never have existed, which is a design decision made before any code is written.

Can a smart contract be changed after deployment?

By default no; a deployed contract is immutable. Teams that need to fix or extend logic engineer an upgrade path in advance, usually a proxy pattern that separates a stable storage contract from a replaceable logic contract. That flexibility adds attack surface, so the decision to make a contract upgradeable at all is a deliberate architecture choice, not a default.

What does the studio deliver on a smart contract engineering engagement?

The studio delivers an architecture-first build: a documented trust model, a privileged-role map, a test suite you own, and a deployment pipeline you control end to end. Clients keep the contracts, the keys, and the ability to walk away. The goal is a system that passes an external audit on the first pass and that you can defend to an investor and an attacker alike.

How La Boétie approaches smart contract engineering

La Boétie is a venture studio, digital agency, and technical consultancy that builds the right thing rather than the thing you first asked for. On smart contract engineering, that means we start with the architecture and the threat model, not the framework logo, and we hand you a system you fully own. Three parts of the engagement carry the weight.

Architecture and build. A flexible team of about five to six engineers, multilingual and multi-timezone, scopes the trust model, the role map, and the upgrade strategy before writing a function, then builds the contracts and the tests you keep. Where clients arrive after a month of DIY AI-tool prototyping with exposed keys and unprotected logic, the studio rebuilds the system properly in a fraction of that time.

Security and audit readiness. We engineer to pass an external audit on the first pass, using Foundry fuzzing against invariants and a role map designed to close the access-control gap that cost the field about $1.83 billion in the first half of 2025. Audit readiness is built in from the first commit, not bolted on before launch.

Fractional technical leadership. For teams that need direction more than hands, the studio operates as a fractional or externalized CTO, owning the on-chain architecture decisions and the security program while your team ships. Clients also get access to the in-house software the team built for itself, including Cortex, Lynkflow, Amorphous, and Socialforge, and always keep ownership of what gets built.

If you are weighing a co-build, a rebuild, or a second opinion on contract code, book a studio intro call with La Boétie. Bring the architecture questions; in smart contract engineering, that is where the money is won or lost.

Conclusion

The field will keep telling you that smart contract engineering is settled, that an audit at the end is enough, and that the framework choice does not matter. The loss data disagrees: $3.35 billion gone in 2025, most of it to architecture and access-control failures that no end-stage audit was positioned to catch. The studio's position is the wedge for every entry in this hub. Decide the trust model, the role map, and the upgrade path first. Choose the toolchain deliberately. Treat the audit as the start of a security program, not its end. And keep ownership of the contracts, the keys, and the exit. Do that, and smart contract engineering stops being a gamble on public code and becomes what it should be: an engineering discipline you can defend in front of anyone.

À lire également :

Sources :

Questions

What is smart contract engineering in one sentence?

Smart contract engineering is the discipline of designing, writing, testing, and deploying self-executing programs that custody and move value on a public blockchain, where the code is public, immutable once deployed, and adversarially attacked from launch. It combines software architecture, security engineering, and the operational discipline of key and role management.

How much does a smart contract engineering audit cost?

A standard DeFi protocol audit costs $50,000 to $100,000 over three to six weeks, according to Sherlock's 2026 pricing reference. A simple ERC-20 token audit runs $5,000 to $15,000, while a cross-chain bridge or ZK-rollup can reach $150,000 to $500,000. Firms price by non-comment source lines of code, and a re-audit after fixes adds $5,000 to $20,000 per pass.

Should I use Foundry or Hardhat?

Use Foundry when auditors and protocol engineers own the test suite, because Solidity-native tests keep everyone in one language and its fuzzing is strong. Use Hardhat when a TypeScript and web team drives the work. Foundry led the 2024 Solidity Developer Survey at 51.1% versus Hardhat's 32.9%, and many teams now run both together.

Why do so many smart contracts get hacked?

Most losses come from architecture, not syntax. In the first half of 2025, access-control failures caused roughly 59% of losses, about $1.83 billion, while pure code bugs caused only 8%, about $263 million, per Hacken. The dominant failure mode is a privileged key or role that should never have existed, which is a design decision made before any code is written.

Can a smart contract be changed after deployment?

By default no; a deployed contract is immutable. Teams that need to fix or extend logic engineer an upgrade path in advance, usually a proxy pattern that separates a stable storage contract from a replaceable logic contract. That flexibility adds attack surface, so the decision to make a contract upgradeable at all is a deliberate architecture choice, not a default.

What does the studio deliver on a smart contract engineering engagement?

The studio delivers an architecture-first build: a documented trust model, a privileged-role map, a test suite you own, and a deployment pipeline you control end to end. Clients keep the contracts, the keys, and the ability to walk away. The goal is a system that passes an external audit on the first pass and that you can defend to an investor and an attacker alike.