Smart contract security is the work of keeping a contract on a blockchain from being misused, drained or locked up. You can't treat it like ordinary application security, since the contract often holds real value itself and once it's deployed you usually can't go back in and fix a flaw. Anyone can also read the code and call its public functions. Mistakes tend to get found fast.
Most pages on this subject come from firms selling audits or are written for Solidity developers. This one is for the CTO or product lead who has to order a contract and answer for it later. It starts with the risks in business terms, then the decisions to settle before coding, including the access control pattern, then testing before deployment, what an outside audit leaves out and who should own each control. Rules and early decisions first, then tests, then the audit is also the order we work in as a smart contract development company.
What Is Smart Contract Security?
A web application with a bug gets a fix the same afternoon. A contract doesn't, and ethereum.org puts the problem plainly in its security guide: contracts can control large amounts of value while running immutable logic, and deployed code usually can't be patched. So on a contract project the security work moves to the front, and any emergency options have to go in before launch, since you can't add them afterward.
An attacker here starts with far more than usual. They can read your code in full, and their transactions are final, so stolen funds rarely come back. Anyone can also call your functions in any order from another contract, so you can't assume a user will come through your front end.
None of this applies if you don't need a chain. If your company is the only one writing the data, a normal database with good audit logs removes the whole category of risk, and we'd tell you so before any contract gets written.
Smart Contract Vulnerabilities in Business Terms
We use the OWASP Smart Contract Top 10: 2026 as a map of what goes wrong. Access control and business logic sit at the top of it, well ahead of reentrancy, the bug many older lists lead with. A company should care about that order, because those top two come out of requirements and design more than clever exploits. We've pulled out the items most likely to touch a business contract.
| Risk | In plain terms | How it looks in a business contract |
|---|---|---|
| Access control | A sensitive function is left open | Anyone can mint, when only the treasury should be able to |
| Business logic | The code does what it says and the rule itself is wrong | A per-transaction limit gets beaten by splitting one large transfer into many small ones |
| Price oracle manipulation | The contract trusts an outside price that can be moved | Collateral is valued from one thin market that an attacker pushes for a block |
| Input validation | Bad values get through | A zero address is accepted as the new admin and control is lost for good |
| Unchecked external calls | The code never checks that its call to another contract worked | A payout bounces, nobody notices, and the books still say paid |
| Reentrancy | Another contract calls back in before state updates | A withdrawal pays first and changes the balance second, so someone repeats it |
| Proxy and upgrade flaws | The upgrade path has holes of its own | An outsider finds an unprotected upgrade function and swaps the logic |
Known patterns and tools do well on the middle of that list. They're far less help on the first two, because no scanner knows that only your treasury should mint, so those need rules a person wrote down.
Smart Contract Best Practices to Settle Before Coding
We ask for the requirements as rules a non-engineer can read. Picture a company issuing a token for shares in a fund. Its first rules could be that only the treasury account can mint, that no single transfer tops a set amount, and that tokens pass only between approved holders. The business owner can read those and spot a mistake, and each one later becomes a test.
We then make three design choices early, because they're painful to change once the contract is live.
Can the contract be upgraded at all? If it can, you're able to fix a flaw, and somebody is also able to change the logic your users rely on. Ethereum's upgrade documentation describes that trade-off directly, and proxy patterns bring complexity and bugs of their own. We might choose a fixed design for a short-lived contract that does little. A platform that will run for years under regulation will probably want an upgrade path with strong controls around it.
Then there's the question of who holds the admin keys. If one person holds one key, you lose control when that key is stolen or that person leaves. So we require several signatures on admin and deployer keys, and we write down how and when they get rotated. You can add a timelock so that holders get a waiting period to react before an admin action takes effect, although that same delay will slow down an emergency fix.
The last choice is how the contract gets paused. While you work out what happened, an emergency stop limits the damage, but it's also a power somebody holds, so settle who can trigger it and who can lift it. On a permissioned network the same question comes up for the whole group, since the members have to agree on who approves a change.
Smart Contract Access Control: Which Pattern Fits
Smart contract access control decides which account may call each sensitive function, such as mint, pause or upgrade, and the pattern you pick sets how many keys an attacker needs and how much notice your users get before an admin acts. Most of the patterns below come from OpenZeppelin's access control guide, and they aren't exclusive: a contract can use roles for daily powers and put a multisig behind the top role.
| Pattern | What it does | Fits when | Watch out for |
|---|---|---|---|
| Ownable | One owner account runs every admin function | There's a single administrator, which OpenZeppelin calls "perfectly reasonable" for that case | One owner is "a single point-of-failure," as the ethereum.org security guide puts it |
| Ownable2Step | Same, but the new owner has to accept the transfer before it takes effect | You use Ownable and want a transfer to a wrong address to fail instead of losing control | It's still one key in charge |
| AccessControl (roles) | Gives separate roles for powers like mint, pause and upgrade | Different people or systems need different powers | The default admin role controls every role, itself included, and OpenZeppelin says it "carries significant risk" |
| AccessControlDefaultAdminRules | Limits the default admin to one account, with a two-step transfer and a delay between the steps | You use roles and want the top role harder to hand over by mistake | Handing over the top role is slow on purpose |
| AccessManager | One contract stores the permissions for many contracts | The system has several contracts that share admins | A wrong setting in that one contract reaches every contract it manages |
| Multisig as owner or admin | A set number of owners must confirm before a transaction runs | Admin, upgrade and deployer powers | It doesn't limit what the admin may do, only how many people must agree |
| TimelockController | Delays admin actions so users can review a change and leave first | Users or partners need notice before the rules change | It slows an emergency fix, and if the accounts holding its proposer or executor roles become unavailable, OpenZeppelin warns the contract "becomes locked indefinitely" |
The "fits when" and "watch out for" columns are our own reading of those docs. One rule sits under every row: the Solidity documentation says "Never use tx.origin for authorization." That's because tx.origin is the account that started the whole transaction, so a malicious contract your admin is tricked into calling would still pass the check.
So what's a multisig? It's a contract account with a list of owners and a threshold, and Safe's documentation describes how a transaction runs only once that number of owners have confirmed it. Put one on admin and upgrade powers and a single stolen key can't act alone, since ethereum.org notes that actions then "require consent from multiple parties." OpenZeppelin notes that Ownable and AccessControl don't address "a misbehaving administrator attacking their own system," and a multisig's signers are administrators too. Its answer is a timelock, whose delay gives users time to review an admin action and exit before it takes effect. In OpenZeppelin's recommended setup a multisig or a DAO holds the timelock's proposer and executor roles, so several people have to agree and users still get notice. Safe also calls modules and guards "security-critical," so any add-on attached to the account belongs in the review like the rest of the code.
Smart Contract Testing Before Deployment
Smart contract testing is how the team that writes a contract shows each of its rules holds before the code reaches a chain where it usually can't be fixed. In practice that means unit tests for each rule, property-based tests (fuzzing and invariants) that throw many inputs and call sequences at it, static analysis that reads the code without running it, and a rehearsal on a test network.
Our security work begins before the code does. We go through each function asking how an attacker would abuse it, and then a second engineer reviews it. We also run static analysis tools over the code, which are good at catching known patterns.
Every rule on the list gets a test. We write some tests purely to try to break the contract, covering the ways a call can fail as well as the ways someone might attack it.
A passing unit test proves little by itself. The ethereum.org security guide calls unit testing minimally effective for security when used alone and suggests combining it with property-based testing, where a tool checks that a rule holds across far more inputs than anyone would write by hand. Its testing guide gives the reason: "Unit tests prove a contract executes correctly for sample data, but whether the contract executes correctly for inputs outside the sample remains unknown." Each method below stops where another starts, so here's what each one checks and what it leaves to the next.
| Method | What it checks | What it misses | Source |
|---|---|---|---|
| Unit and negative tests | Each rule with chosen inputs, including calls that should fail, which ethereum.org calls tests "that check if a function fails for the wrong inputs" | Any input outside the samples someone picked | ethereum.org testing |
| Integration tests | Calls between contracts, and between functions in the same contract | Whether the business rule itself is right | ethereum.org testing |
| Fuzz testing | One rule against many generated inputs; Forge fuzzes any test function that takes parameters | Bugs that only show up after a particular order of calls | Foundry testing |
| Invariant testing | Properties that must hold after every call while random sequences of calls run, such as a supply cap that's never passed | Any property nobody wrote down | Foundry invariant testing |
| Static analysis | The code read without running it, flagged against known patterns | Deeper flaws, since analyzers are "generally unsound at detecting deeper vulnerabilities, and may produce excessive false positives" | ethereum.org testing |
| Formal verification | A property proven with math | Properties nobody specified, and it costs specialist time | ethereum.org formal verification |
| Test network | The deployment and real use, on a network that "works exactly like Ethereum Mainnet" except its ether has no real-world value | Behavior that only appears when real money is at stake | ethereum.org testing |
Foundry or Hardhat? Both run tests written in Solidity, and neither makes a contract safe on its own, since the tests you write matter more than the runner. Foundry describes itself as "a fast, portable, and modular toolkit for Ethereum development." Hardhat 3 runs tests in both Solidity and TypeScript. Its docs say Solidity tests are "the only place where you can use built-in fuzzing and invariant testing," while TypeScript tests run the contracts "in a complete simulation of a blockchain," which is closer to how a front end or a bot will call them. When a fuzz run fails, keep its seed and its setup. Foundry's docs say a pinned seed helps you reproduce the failure, and they also warn, "The seed alone does not guarantee identical inputs."
Contracts go to a test network before production, and on a project with an audit we pilot there with real users once the audit findings are fixed.
Pre-Deployment Checklist
Before a contract goes to production, every item below should be done and someone on the project should be able to say who did it. Most of them point back to a section above.
- The rules are written in plain language, and a business owner has signed them off.
- Every rule has a test, including negative tests and tests written to break the contract.
- Rules that move value also have fuzz or invariant tests.
- Static analysis has run, and each finding has been triaged, since some will be false positives.
- Every admin, upgrade and pause power is mapped to a pattern from the access control table, admin keys sit behind a multisig, and the timelock decision is written down.
- The deployment has been rehearsed on a test network.
- If the contract will hold real value, an outside audit is booked, its findings are fixed, and every line changed afterward has been re-checked.
- Event monitoring is ready, and its alerts go to a named person.
What a Smart Contract Audit Covers and Misses
A smart contract audit is an independent review by a security firm, and it covers one fixed version of the code at a point in time. We don't sell audits. If a contract is going to hold real value, an outside firm audits it, because the people who wrote the code shouldn't be the ones signing off on it. We book that audit before production, and whatever the firm finds gets fixed before launch.
Projects slip on timing here, because good independent auditors are often booked weeks out, so we reserve a slot as early as we can. The audit also goes deeper when the firm gets the rule list, the threat notes and a frozen version of the code with its tests on day one, since its auditors don't have to guess what you meant and have time left for real problems.
Read the report as one layer of review. Ethereum.org warns against treating audits as a silver bullet, since they won't catch every bug. Scope is the other limit. The firm usually won't look at where your keys are kept or who can reach the deployment pipeline, and it won't check whether your database agrees with the chain or whether the business rule was right to begin with. Touch a line after the audit and that line was never reviewed, which is why you plan a re-check. A bug bounty on the live contract is something some teams add on top, paying outside researchers for reports at rates that scale with the funds at risk.
Security Outside the Contract
On many projects the contract is the smallest piece of the job and much of the risk sits around it.
Take keys. No person in a business application should be holding a private key, so it goes to a custody provider or into a hardware security module. The finance clerk approving a transfer uses her normal login and never sees it, and if the amount goes over a limit you set, it sits waiting for a second person. The books are the other big one. Each event a contract emits gets picked up by our services and copied into an ordinary database for reports and search, and a scheduled job compares that database against the chain and tells someone on your team if the two disagree. Skip that check and a missed event turns into a quiet error in your books.
Your ERP and CRM connect through API integration solutions built to retry safely when the chain lags. The off-chain code has ordinary risks and gets the usual application security work, with secrets kept out of it and access controlled and logged. Once a contract is live we keep watching its events, since odd activity is often the first sign of trouble.
Who Owns Which Control
Two teams can each assume the other owns a control, and problems often start in that gap, so ownership is best written down during architecture, before anything gets built.
| Control | Owner | Note |
|---|---|---|
| Written contract rules | Your business owner, with engineering | Signed off before coding |
| Threat notes, tests, peer review | Engineering team | Done per function |
| Independent audit | Outside security firm | Booked before production |
| Legal questions on tokens, KYC, securities | Your counsel | We build to their decisions |
| Key custody | Custody provider or your security team | Rotation schedule in writing |
| Transfer approvals over the limit | Your finance or operations team | Second approver named |
| Event monitoring and chain-to-database checks | Engineering, then whoever runs support | Alerts go to a named person |
The incident plan belongs in the same document. Before launch, name the person who can pause the contract and the person who talks to holders and partners, and agree what evidence to keep. The middle of an incident is a bad moment to start working that out.
FAQ
What makes contract security different from traditional application security?
Deployed code is hard to change and transactions are final, and on top of that the code and its state are public. You can patch a normal application quickly and reverse a bad transaction, and an attacker usually can't read your source. A contract gives you none of that, so far more of the work has to happen before launch.
When should a smart contract audit happen?
After the code is complete and tested, while there's still time before production. The slot should be booked during planning, because good firms fill up weeks ahead, and significant changes need another audit before they're released.
Is testing the same as an audit?
No. Testing is the builders' own proof that each rule holds, and it runs all through development. An audit is an outside firm's review of one frozen version of the code. Neither one catches everything: ethereum.org says audits "won't catch every bug," and tests only check the rules someone thought to write.
Do we need a multisig if we already use roles?
Usually, yes, because they solve different problems. Roles split powers between accounts, so the account that mints can't also upgrade. A multisig makes one of those powers need several people. The two work together, and OpenZeppelin's guide suggests a 2-of-3 multisig run by project leads as the owner instead of a single account.
Can automated tools replace a manual review?
No. Static analysis will find known patterns, but a tool has no idea whether your business rule is correct, and most of the serious risks in the OWASP list need a person who knows what the contract is meant to do.
Does Vortex audit smart contracts?
No. We write contracts, tests and the software around them, and an independent firm audits anything that will hold real value. We book that audit and fix what it finds before launch.
What is the first step to a safer contract?
Write the plain rules the contract has to enforce and get a business owner to approve them. Then ask whether the project needs a blockchain at all, and settle upgrades, admin keys and pausing before anyone writes code.
Test the Plan Before You Fund the Contract
Bring your use case and a list of everyone who'd write to the ledger. On the call we'll first compare it with a plain database option. If a chain does fit, we'll go through the rules and the audit timing and show what our web3 development services would cover.
Book a Technical Discovery Call · Get a Web3 Project Estimate