Smart contract design and development: how to build one, step by step
How we design and develop smart contracts for production: specs, architecture patterns, languages, testing, audits and deployment, plus NFT contract specifics and what smart contracts are used for.
By Przemysław Paczoski, CEO & Founder at 23studio
Published Updated 9 min read

Developing a smart contract means writing a short program that runs on a blockchain and holds or moves value by its own rules. The work splits into design (spec, roles, state, failure cases), implementation in Solidity, Rust or Move, testing with fuzzing and invariants, an external audit, and a scripted deployment to mainnet behind a multisig.
The code is usually the smallest part. Most failures we see in other teams' contracts trace back to the design stage: an admin role nobody thought about, an oracle that can be pushed, a token that behaves strangely. This guide walks through how we design and develop smart contracts for clients at 23studio, then covers what smart contracts are and where they are used.
What is a smart contract?
A smart contract is code deployed to a blockchain address. Anyone can call its functions by sending a transaction, every node runs the same code, and the result is recorded on-chain. It follows "if this, then that" logic: if a borrower's collateral falls below a threshold, the contract lets anyone liquidate it; if a buyer sends the right amount, the contract transfers the NFT.
Three properties make smart contracts useful and also make them risky:
- They execute automatically. No one has to approve a transaction that meets the rules, including an attacker's.
- They are transparent. Code and state are public, so users can verify behaviour and attackers can study it.
- They are hard to change. A deployed contract stays as written unless you built in an upgrade path, which adds its own risk.
| Smart contract | Traditional contract | |
|---|---|---|
| Execution | Automatic when conditions are met | Manual, by the parties or an intermediary |
| Enforcement | Code and consensus | Courts, banks, notaries |
| Visibility | Public on-chain | Private between parties |
| Changes | Only through pre-built upgrade or migration | Amendment by agreement |
| Cost | Gas per transaction, plus development and audit | Legal and administrative fees |
How to design a smart contract
Designing smart contracts is mostly about deciding what the contract must never do. We write this down before anyone opens an editor.
1. Write a one-page spec
List every actor (users, admins, keepers, oracles, other contracts), every action each one can take, and the state the contract stores. For each action, write the preconditions and what changes. If you can't describe the system on one page, it is probably too big for a first version.
2. Define invariants
Invariants are statements that must hold after every transaction. Examples: "total shares equal the sum of user shares", "the vault never holds less than total deposits minus withdrawals", "only the timelock can change fees". These become your most valuable tests later.
3. Decide what goes on-chain
Put on-chain only what needs trustless enforcement: custody, settlement, ownership, governance. Keep everything else off-chain: search, analytics, user profiles, notifications. On-chain storage is expensive and public. A typical dApp pairs a small contract with an indexer and a regular backend.
4. Map privileges and failure modes
Who can pause, upgrade, mint, change parameters or withdraw? Each privileged role should sit behind a multisig, and the most dangerous ones behind a timelock. Then ask what happens if each external dependency fails: the oracle returns stale data, a token charges a transfer fee, a bridge pauses, or the sequencer goes down.
5. Choose patterns, not inventions
Use battle-tested building blocks wherever possible:
| Need | Common pattern |
|---|---|
| Tokens | OpenZeppelin ERC-20, ERC-721, ERC-1155, ERC-4626 vaults |
| Access control | Ownable2Step, AccessControl, multisig plus timelock |
| Upgrades | UUPS or transparent proxy, or no upgrades at all |
| Safety | Checks-effects-interactions, ReentrancyGuard, pull payments |
| External prices | Chainlink or Pyth feeds with staleness checks, TWAPs as backup |
| Emergency | Pausable with a narrow scope and a clear unpause path |
Upgradeability deserves its own decision. It lets you fix bugs, but it also lets a compromised admin key replace your logic. We cover the trade-offs in our guide to upgradeable smart contracts and proxy patterns.
How to develop a smart contract, step by step
Once the design is agreed, development follows the same sequence on every project we run.
- Pick the chain and language. Solidity or Vyper for Ethereum and EVM chains (Base, Arbitrum, HyperEVM, Polygon), Rust for Solana (with Anchor) and other non-EVM chains, Move for Aptos and Sui. Liquidity, users and audit availability should decide this more than developer preference. Our Rust vs Solidity comparison goes deeper.
- Set up the toolchain. For EVM work we use Foundry for compilation, unit tests, fuzzing and deployment scripts, with OpenZeppelin libraries. Hardhat is still common in older codebases. Anchor is the default framework on Solana.
- Write the contracts small. Short functions, explicit errors, events for every state change your frontend or indexer needs. Avoid clever gas tricks until tests are complete.
- Test in layers. Unit tests for each function, fuzz tests with random inputs, invariant tests for the properties from your design, and fork tests against real mainnet state for integrations with other protocols. Static analysis with Slither catches common mistakes early.
- Deploy to testnet and run it like production. Use the same deployment scripts, the same multisig setup and a real frontend. Let a few people try to break it.
- Get an external audit. Freeze the code, hand over the spec and invariants, and fix findings before launch. Our smart contract audit checklist covers how to prepare and what to do afterwards.
- Deploy to mainnet with scripts, not by hand. Verify source code on the block explorer, transfer ownership to a multisig, and double-check every constructor argument.
- Monitor after launch. Set up alerts on unusual events and large withdrawals, run a bug bounty, and keep an incident runbook with who can pause what.
On a recent project for HyperBloom, a DEX aggregator and auto-compounding vault platform on HyperEVM, this sequence ended with an external audit of the vaults by Pashov before launch. Having the spec and tests ready before an audit starts is what keeps the audit focused on real risks instead of on explaining the code.
How long and how much?
A simple, audited token or NFT contract takes a few weeks. A DeFi protocol with vaults, oracles and governance takes several months, and the audit alone can take weeks to book. Deployment gas is cents on L2s. On Ethereum L1 it was a few dollars for a typical contract at the low gas prices of late 2026, and can reach a few hundred for a large DeFi system when the network is busy. Our breakdown of how much it costs to deploy a smart contract has per-chain numbers.
NFT smart contract development
NFT contracts look simple and often aren't. Decisions to make up front:
- Standard. ERC-721 for unique items, ERC-1155 for editions and game items where many copies share an ID. Use ERC-721A or similar only if batch minting gas matters.
- Metadata. Where the image and attributes live (IPFS, Arweave, or your own server) decides whether the NFT survives your company. Freeze metadata if buyers expect it to be permanent.
- Royalties. ERC-2981 tells marketplaces what royalty you want, but most marketplaces treat it as optional. If royalties are core to your business, you need transfer restrictions or your own marketplace contract, which limits where tokens can trade.
- Minting. Allowlists with Merkle proofs or signatures, per-wallet limits, and a withdrawal function that can't be blocked.
- Marketplace features. Auctions and offers need escrow logic, careful handling of refunds, and protection against bidders who make refunds fail.
Can I use a drag-and-drop smart contract builder?
For a standard token or NFT collection, generators like the OpenZeppelin Contracts Wizard or thirdweb produce reasonable, well-tested code, and that is often the right choice. They stop being enough once you need custom logic: vesting with edge cases, fees, staking, integrations with other protocols. At that point the generated code is a starting point, not a finished product, and it still needs review.
What are smart contracts used for?
| Area | What the contract does | Example |
|---|---|---|
| DeFi | Lending, trading, vaults, derivatives without a custodian | Aave, Uniswap, Hyperliquid |
| Tokens and stablecoins | Issuance, transfers, compliance rules | USDC, tokenized treasuries |
| NFTs and gaming | Ownership, minting, trading of unique items | ERC-721 collections, in-game items |
| DAOs | Voting, treasury control, proposal execution | Governor contracts with a timelock |
| Real-world assets | Transfer-restricted securities, funds, real estate shares | ERC-3643 tokens |
| Payments | Escrow, payouts, subscriptions | Stablecoin checkout contracts |
Enterprise blockchain projects from the late 2010s offer a lesson here. Several supply chain platforms built on permissioned ledgers shut down after struggling to get enough industry partners on board. IBM and Maersk's TradeLens is the best-known case: the two companies announced its closure in November 2022 because it never became commercially viable, and took it offline in early 2023. The technology worked. The shared incentive to use it didn't. Smart contracts succeed where users want a neutral party nobody controls, such as open financial markets, and struggle where one company would happily run the database.
Risks to plan for
| Risk | What goes wrong | Mitigation |
|---|---|---|
| Logic bugs | Funds drained or locked | Invariant testing, audits, bug bounties |
| Admin key compromise | Attacker upgrades or drains contracts | Multisig, timelocks, minimal privileges |
| Oracle manipulation | Wrong prices trigger bad liquidations | Multiple feeds, staleness checks, limits |
| Reentrancy and external calls | Callbacks re-enter before state updates | Checks-effects-interactions, guards |
| Immutability | A bug can't be patched | Upgrade path or migration plan, decided up front |
| Regulation | Token or product falls under securities or MiCA rules | Legal review before launch |
Frequently asked questions
Which programming languages are used to write smart contracts?
Solidity dominates on Ethereum and EVM chains. Vyper is a smaller Python-like alternative. Rust is used on Solana, Near and CosmWasm chains, and Move on Aptos and Sui.
Can smart contracts be changed after deployment?
Not directly. You can design an upgrade path with a proxy contract, or deploy a new version and migrate users. Both have trade-offs you should choose before launch.
How long does it take to learn smart contract development?
A developer with solid programming experience can write basic Solidity in a few weeks. Writing contracts you would trust with other people's money takes much longer, mostly spent learning security patterns and past exploits.
Do smart contracts need oracles?
Only if they depend on data from outside the chain, such as prices, weather, sports results or identity checks. Contracts that only move on-chain assets don't.
Are smart contracts legally binding?
Some jurisdictions recognize them as valid ways to form or perform an agreement, but rules vary. Treat the code as the execution layer and keep a legal agreement alongside it when real-world obligations are involved.
Do smart contracts keep data private?
No. On public chains, code and state are visible to everyone. Privacy needs zero-knowledge proofs, privacy-focused chains or off-chain storage. We built ZK-based private transfers on HyperEVM in our Blanksquare integration.
Working with us
We design, build and audit-prepare smart contracts on EVM chains and beyond, from token contracts to DEX aggregators and vaults. If you have a spec, or just an idea that needs one, talk to our smart contract development team.
Keep reading

Smart contract development cost in 2026: prices by contract type
What it costs to write, test and audit a smart contract in 2026, from a $7,000 token to a $500,000+ lending protocol or bridge, plus freelance vs agency vs in-house and the hidden costs.

Rust vs Solidity for smart contracts: which to choose in 2026
Rust vs Solidity compared for smart contracts: which chains each runs on, safety, tooling, hiring and audits, and a practical guide to when each one is the right pick.

Upgradeable smart contracts: proxy patterns, risks and when to skip
Transparent, UUPS, beacon and diamond proxies compared, plus storage collisions, initializer bugs, timelocks and the cases where an immutable contract is the better call.