---
title: "Smart contracts, tested as if someone will attack them"
url: https://soliditylabs.tech/services/blockchain-development/smart-contract-development/
description: "Solidity Labs writes smart contracts in Solidity with unit, fuzz and invariant tests in Foundry, static analysis and preparation for an independent audit."
source: Solidity Labs (https://soliditylabs.tech)
---

Blockchain · Smart contracts

# Smart contracts, tested as if _someone will attack them_

Solidity on audited building blocks, with unit, fuzz and invariant tests in Foundry, static analysis on every change and a codebase prepared for independent audit. A second reviewer’s line-by-line pass is recommended and scoped in the proposal.

[Get a quote](/contact/get-a-quote/) [Book a free call](/contact/book-consultation/)

Free discovery callNDA on requestFixed proposal after scoping

1.  **Access control**who may call what
2.  **Role tests**every function, every role
3.  **Reentrancy**call ordering
4.  **Fuzzed call orders**checks-effects-interactions
5.  **Oracle manipulation**price moved in a block
6.  **Oracle guards**staleness · deviation · TWAP
7.  **Precision & rounding**value leaks over time
8.  **Invariant tests**totals always add up
9.  **Signature replay**one approval used twice
10.  **Nonce & domain**EIP-712 replay tests
11.  **Upgrade mistakes**storage · initializers
12.  **Upgrade checks**storage layout diffs

Fig. 1 — Each common failure has its own test: role tests for access control, fuzzed call orders for reentrancy, oracle guards for manipulation, invariants for rounding, nonce and domain tests for replay, and storage-layout checks for upgrades.

In short

Smart contract development is writing the on-chain programs that hold assets and enforce rules on a blockchain. Solidity Labs writes contracts in Solidity (and Rust for Solana) on OpenZeppelin building blocks, tests them with unit, fuzz and invariant tests in Foundry, runs the Slither static analyzer on every change, and prepares high-value contracts for independent audit. A second reviewer’s line-by-line pass is recommended and agreed in the proposal.

Definition

## What makes smart contract development different from other software?

**Deployed code is public and permanent.** Anyone can read it, call it in any order and with any input, and keep trying until something breaks.

A smart contract is a program deployed to a blockchain that holds state (balances, positions, permissions) and changes it according to its code. Once deployed, it is public and, unless designed to be upgradeable, can’t be changed. Every function is callable by anyone, in any order, with any input, often in the same block as other contracts reacting to it. Pending transactions are usually visible before they are included in a block, so others can see a call coming and act first.

That changes how you build. Specification comes first, as properties you can test: “no user can withdraw more than they deposited”, “only the minter role can mint”, “total supply always equals the sum of balances”. Code stays small and leans on audited libraries. Testing goes beyond examples to fuzzing (random inputs) and invariants (properties that must hold after any sequence of calls). Deployment, admin keys and upgrades are part of the design, not afterthoughts.

Our full engineering standard, from style rules to release checks, is on how we write, test and ship Solidity.

Problems we solve

## Where contracts usually fail

1.  ### Access control mistakes
    
    An unprotected initializer or admin function lets anyone take control of the contract. A proxy’s implementation contract left uninitialized is a classic case. Every privileged function gets an explicit role and a test proving others can’t call it, and every implementation locks its initializers in its constructor.
    
2.  ### Reentrancy and call ordering
    
    External calls before state updates let attackers re-enter. We follow checks-effects-interactions and add reentrancy guards where calls are unavoidable.
    
3.  ### Oracle manipulation
    
    A spot price read from one pool can be moved within a single transaction, often with a flash loan. We read oracle feeds with staleness and deviation checks, and use time-weighted prices only from pools deep enough to make moving them expensive.
    
4.  ### Precision and rounding
    
    Integer division and decimal mismatches leak value. Rounding favors the contract (down when paying out, up when charging), as the ERC-4626 vault standard recommends, and fuzz tests probe the edges.
    
5.  ### Signature replay
    
    A signed message without a nonce, a deadline and a domain naming the chain and the contract can be used again. EIP-712 typed data supplies the domain but leaves replay protection to the contract, so we add a nonce and a deadline to every signed message.
    
6.  ### Unsafe upgrades
    
    A storage collision or an unprotected upgrade function breaks a proxy. We use OpenZeppelin’s upgrade patterns, check the storage layout against the previous version before every upgrade, and put upgrades behind a multisig and a timelock.
    

What we build

## What we build

### Token contracts

ERC-20, ERC-721, ERC-1155 and permissioned tokens, with vesting, minting roles and supply controls.

### DeFi primitives

Vaults (ERC-4626), lending markets, staking, AMMs and reward distribution.

### Tokenization contracts

ERC-3643 tokens, identity registries and compliance modules for [real-world assets](/services/rwa-tokenization/).

### Payments and escrow

Stablecoin payment flows, escrow, streaming payments and settlement contracts.

### Governance

Governor contracts, timelocks and multisig setups.

### Account abstraction

ERC-4337 smart accounts, paymasters and session keys.

### Deployment & verification

Deterministic deployment scripts, verified source on block explorers, role handover to your multisig.

### Monitoring

Alerts on admin actions, large movements and invariant breaches, with a pause-and-respond runbook.

How it works

## Our contract lifecycle

Specification to monitoring. The depth of each step scales with the value at risk.

1.  **Spec & threat model**
2.  **Develop**Solidity · OpenZeppelin
3.  **Unit · fuzz · invariant**Foundry
4.  **Static analysis**Slither
5.  **Review pass**scoped in proposal
6.  **Testnet**realistic scenarios
7.  **Upgrade via timelock**if upgradeable
8.  **Monitor & respond**alerts · pause runbook
9.  **Mainnet deploy**verified source
10.  **Fix & re-test**
11.  **Independent audit**high-value contracts

Fig. 2 — Specification to monitoring. Tests and static analysis come before mainnet; a second reviewer's pass and, for contracts holding meaningful value, an independent audit are recommended and agreed in the proposal.

Specification

Roles, states, invariants and an attack-scenario list, reviewed with you before coding.

Development

Small contracts on OpenZeppelin; NatSpec comments; events for every state change.

Tests

Foundry unit tests, fuzz tests on every external function, invariant tests with handler contracts, fork tests against live integrations.

Analysis

Slither on every pull request; findings fixed or documented with a reason.

Review

We recommend a second reviewer’s line-by-line pass against a vulnerability checklist; who reviews, and how, is agreed in the proposal.

Audit & deploy

Independent audit recommended when value is at stake; scripted deployment; admin roles to your multisig.

From the codebase

## What our contracts look like

The example below is the shape of almost every state-changing function we write: checks, then effects, then interactions, with an event at the end. It is simple on purpose: in larger code, an external call made before the state update is how reentrancy bugs get in.

```solidity
// Vault redemption (ERC-4626 style, caller redeems own shares):
// checks → effects → interactions, guarded against reentrancy.
function redeem(uint256 shares, address receiver) external nonReentrant returns (uint256 assets) {
    if (shares == 0) revert ZeroShares();                       // checks
    assets = previewRedeem(shares);                             // rounds down, in the vault's favor
    if (assets == 0) revert ZeroAssets();

    _burn(msg.sender, shares);                                  // effects before any external call
    totalManaged -= assets;

    asset.safeTransfer(receiver, assets);                       // interaction last
    emit Withdraw(msg.sender, receiver, msg.sender, assets, shares); // sender, receiver, owner
}
```

And this is the kind of property we test with an invariant: whatever sequence of deposits, withdrawals and transfers the fuzzer tries, the vault never owes more than it holds.

```solidity
// Foundry invariant test (handler-based): solvency must hold after any call sequence.
function invariant_vaultIsSolvent() public view {
    assertGe(asset.balanceOf(address(vault)), vault.totalAssets(), "vault owes more than it holds");
}

function invariant_supplyMatchesBalances() public view {
    assertEq(vault.totalSupply(), handler.sumOfBalances(), "share supply drifted");
}
```

Every contract we deliver comes with a test report (coverage, fuzz runs, invariant runs), the static-analysis results with each finding resolved or explained, deployment scripts and a short operations runbook. When a review pass is in the proposal, its checklist is delivered too.

**Before mainnet we check:**

-   Constructor and initializer arguments match the specification, and every implementation contract has its initializers disabled.
-   Every admin, minter, pauser and upgrader role is held by your multisig, and the deployer address holds no role.
-   Source code is verified on the block explorer for every deployed address.
-   For an upgrade, the storage layout matches the previous version, and the timelock delay is the one in the specification.
-   Monitoring alerts are live before the contract accepts funds.
-   New contracts that will hold value start with deposit caps, raised as they prove themselves in production.

Process

## How we run it

1.  ### Specification
    
    Properties, roles, upgrade strategy and threat model written and agreed.
    
    Written spec
    
2.  ### Fixed proposal
    
    Contracts, test coverage targets, audit scope and deployment plan as milestones, with milestone-based payments agreed in the proposal.
    
    Fixed proposal
    
3.  ### Build with tests
    
    Tests written alongside code; coverage and invariant results shown in demos at a cadence agreed in the proposal.
    
    Regular demos
    
4.  ### Review and audit
    
    Testnet deployment, then the review pass and independent audit agreed in the proposal, fixes and re-test.
    
    Testnet release
    
5.  ### Mainnet and monitoring
    
    Verified deployment, role handover, monitoring alerts and runbook.
    
    Handover
    

Technology

## Tools we use for this

### Languages

-   Solidity
-   Rust

### Frameworks

-   Foundry
-   Hardhat
-   OpenZeppelin
-   Solady

### Security tools

-   Slither
-   Echidna
-   Halmos

### Chains

-   Ethereum
-   Base
-   Arbitrum
-   Optimism
-   Polygon
-   BNB Chain
-   Avalanche
-   Solana

### Operations

-   Safe multisig
-   OpenZeppelin Monitor
-   Tenderly
-   Etherscan verification

Scope drivers

## What shapes scope

We don’t publish prices or week counts, because they depend on scope. These are the factors that actually move them.

01

### Value at risk

The more value a contract holds, the deeper the testing, formal properties and audit scope.

02

### Novelty of the logic

Standard tokens and vaults on audited libraries are small; novel pricing, liquidation or cross-chain logic is large.

03

### External integrations

Oracles, DEX routers, lending markets and bridges need fork tests and failure handling.

04

### Upgradeability and governance

Proxies, timelocks and governance add design work and audit surface.

05

### Number of chains

Each chain adds deployment, verification, testing and monitoring.

06

### Audit scope

An independent audit is a separate cost from an audit firm; scope depends on lines of code and complexity.

**Typical shapes:** a fixed-scope contract build with testnet deployment, then an audit-and-mainnet phase. For existing code we start with a [security review](/services/blockchain-development/smart-contract-audit/).

### Every engagement includes

-   Source code & IP transfer
-   Documentation
-   Handover session
-   Post-launch support as agreed
-   Demos at an agreed cadence

**We give a fixed proposal after a free discovery call and a written scope of work.** [Prepare a brief with the Project Planner](/resources/project-planner/)

Comparison

## Upgradeable or immutable?

Immutable

Upgradeable (UUPS / transparent proxy)

Trust model

Users trust the code alone

Users also trust whoever controls upgrades

Fixing bugs

Redeploy and migrate

Upgrade in place, through multisig + timelock

Audit surface

Smaller

Larger (proxy, storage layout, admin)

Typical fit

Tokens, simple vaults, mature protocols

Early-stage protocols, regulated assets needing changes

Honest guidance

## When not to choose this

When not to use this

-   **The logic doesn’t need a blockchain.** If nobody needs to verify state independently and there are no assets on-chain, a database is cheaper and easier.
-   **You need to launch before an audit is possible for a high-value contract.** Launch with caps and limits, or wait; don’t skip security for speed.
-   **The token’s legal status is unclear.** Get legal advice before writing a contract that will be sold to the public.

Scope boundary

## What we engineer, and what others provide

### We engineer

-   Specification, contracts, tests and static analysis
-   Deployment scripts, verification and monitoring alerts
-   Audit coordination and fix implementation

### You provide

-   Product decisions and economic design sign-off
-   Multisig signers and key custody
-   Legal review of token and protocol

### Licensed partners & providers

-   Independent audit firms
-   Oracle and infrastructure providers
-   Legal counsel

Security & quality

## How we keep it safe and correct

-   Unit, fuzz and invariant tests in Foundry; fork tests for integrations
-   Slither static analysis on every change; findings triaged and documented
-   Recommended: a second reviewer’s line-by-line pass against a vulnerability checklist, scoped in the proposal
-   Admin roles handed to your multisig (hardware keys recommended); timelocks on upgrades
-   Independent audit recommended for contracts holding meaningful value
-   Monitoring alerts and a pause-and-respond runbook, handed over to your team

Engineering example

## Tokenized transfer compliance

Attempt transfers between synthetic investors and watch an ERC-3643-style rule engine allow or block each one, with the reason.

Illustrative engineering example: synthetic data, not a client project. Verified case studies will appear here when consented ones exist.

FAQ

## Questions buyers ask us

Not covered here? [Ask us directly](/contact/) — a person reads every message.

### ### How much does smart contract development cost?

It depends on the value at risk, how novel the logic is, integrations, upgradeability, the number of chains and the audit scope. We don’t publish prices; after a free discovery call and a written specification we send a fixed proposal.

### ### How long does smart contract development take?

The schedule is in the proposal once the specification is agreed. Testing and audit are a large share of it by design; we don’t compress them for high-value contracts.

### ### Do you audit your own contracts?

We test and analyze our own code: unit, fuzz and invariant tests and static analysis. We recommend a second reviewer’s line-by-line pass, and its scope is agreed in the proposal. For contracts holding meaningful value, we prepare for and coordinate an independent audit, because no team should be the only auditor of its own code.

### ### Which languages and chains do you use?

Solidity on Ethereum and EVM chains (Base, Arbitrum, Optimism, Polygon, BNB Chain, Avalanche) and Rust with Anchor on Solana.

### ### What are fuzz and invariant tests?

Fuzz tests call functions with many random inputs to find edge cases. Invariant tests run random sequences of calls and check properties that must always hold, such as total supply matching the sum of balances.

### ### Who controls the contracts after deployment?

You do. Admin and upgrade roles go to multisig wallets your team controls; we recommend hardware keys for every signer. We hand over and keep no production keys.

### ### Can you work on contracts written by another team?

Yes. We start with a review and test-coverage assessment, then fix, extend or prepare them for audit.

### ### Do you write upgradeable contracts?

When it’s the right trade-off. Upgradeability adds flexibility and trust assumptions; we document who can upgrade, behind a multisig and timelock.

### ### Can AI write smart contracts?

AI tools help with boilerplate and as an extra reviewer, but every line we ship is written or checked by an engineer and covered by tests. We don’t ship unreviewed AI-generated contract code.

Keep exploring

## Related services and reading

-   [Smart Contract Security & AuditSecurity review and audit preparation](/services/blockchain-development/smart-contract-audit/)

### From the blog

![](/assets/img/r/erc-3643-explained-480.png)

RWA Tokenization

### [ERC-3643 Explained: Permissioned Tokens for Regulated Assets](/blog/erc-3643-explained/)

ERC-3643 is the Ethereum standard for tokens that only verified, eligible investors may hold. Here is how its identity registry, claims, compliance modules and agent roles work, and what the standard does not do for you.

Solidity Labs · October 16, 2026 · 8 min read

Last reviewed: December 2026 Reviewed by our independent expert review under our [editorial policy](/editorial-policy/)
