MrDeFi
Ethereum2026-06-194 min read

How to Deploy a Smart Contract on Ethereum: Step-by-Step

A step-by-step overview of writing, compiling, testing, and deploying a simple Ethereum smart contract using tools like Remix or Hardhat.

Deploying a smart contract on Ethereum means writing the contract code, compiling it into EVM bytecode, testing it thoroughly, and finally submitting a special transaction that publishes that bytecode permanently to the blockchain, creating a new contract address. The process typically flows through a testnet before ever touching mainnet, and each step carries real consequences once completed.

Step 1: Write the contract

Most Ethereum smart contracts are written in Solidity, covered in /blog/what-is-solidity-programming-language. At this stage, a developer defines the contract's state variables, functions, and access rules — deciding what data it stores on-chain, what actions it allows, and who's permitted to call which functions.

Step 2: Compile the code

The Solidity source code is run through a compiler, which translates the human-readable contract into EVM bytecode — the actual instructions Ethereum nodes execute — along with an Application Binary Interface (see /blog/what-is-an-abi-ethereum) that describes how external applications can call the contract's functions. Compilation also surfaces basic errors, like type mismatches or syntax mistakes, before any deployment attempt.

Step 3: Test locally and on a testnet

Before deploying anywhere with real value, contracts are tested extensively using a development framework — a comparison of the leading options is covered in /blog/what-is-hardhat-vs-truffle. Testing typically happens first on a local simulated blockchain (fast and free, ideal for rapid iteration), then on a public testnet like the ones covered in /blog/what-is-an-ethereum-testnet, which more closely mirrors real network conditions, gas costs, and interactions with other deployed contracts.

Step 4: Get an independent security review

For any contract handling meaningful value, an audit — described in /blog/how-to-audit-a-smart-contract — is a standard step before mainnet deployment, checking for the vulnerability patterns covered in /blog/common-smart-contract-vulnerabilities. Skipping this step on anything beyond a small personal experiment is one of the most common causes of preventable losses in the DeFi space.

Step 5: Deploy to mainnet

Deployment itself is a special kind of transaction: instead of specifying a recipient address, the transaction's data field contains the compiled bytecode, and Ethereum creates a new contract address to hold it, calculated from the deploying account's address and its /blog/what-is-a-nonce-ethereum. This transaction requires paying /glossary/gas proportional to the contract's code size and any initialization logic that runs during deployment, which can be substantial for complex contracts, following the gas mechanics covered in /blog/what-is-gas-limit-vs-gas-price.

Step 6: Verify the source code

After deployment, developers typically submit the contract's source code to a block explorer for verification, which lets anyone confirm the deployed bytecode actually matches the published source — a transparency step that lets users read exactly what a contract does before interacting with it, as discussed in /blog/how-to-read-etherscan-transactions.

A simplified deployment pipeline

Stage What happens Typical tools
Write Author the contract logic Solidity
Compile Translate to EVM bytecode + generate ABI Solidity compiler
Test Local and testnet testing for correctness Hardhat, Foundry, Truffle
Audit Independent security review Third-party auditing firms
Deploy Submit contract-creation transaction Hardhat, Remix, deployment scripts
Verify Publish and confirm matching source code Block explorer verification tools

Constructor arguments and initial configuration

Many contracts require specific configuration values at the moment of deployment — for example, an initial owner address, a token's name and symbol, or a starting parameter that shapes the contract's behavior going forward. These are typically supplied through a constructor function that runs exactly once, at deployment time, and whose values often cannot be changed afterward unless the contract was specifically designed with that flexibility in mind. Getting these initial values wrong is a surprisingly common and sometimes costly mistake — double-checking constructor arguments against a deployment script before submitting the transaction is a simple step that prevents having to redeploy an otherwise-correct contract from scratch.

Why deployment is treated with such caution

Once deployed, a contract's code is generally immutable unless it was specifically designed with an upgrade mechanism, such as the pattern covered in /blog/what-is-proxy-contract-upgradeable. A bug discovered after deployment often can't simply be patched — it may require deploying an entirely new contract and migrating funds and users, which is far more disruptive (and sometimes impossible) compared to fixing a bug before launch.

Post-deployment monitoring

Deployment isn't necessarily the final step for a responsibly run project. Many teams continue monitoring their deployed contracts afterward, watching for unusual transaction patterns, unexpected drops in a protocol's held assets, or attempted exploits that a bug bounty program or automated on-chain monitoring service might catch early. This ongoing vigilance matters especially for contracts without an upgrade mechanism, where the only real defense against an in-progress exploit may be pausing specific functions (if that capability was deliberately built in) rather than fixing the underlying code directly.

Bottom line

Deploying a smart contract runs through a deliberate sequence — write, compile, test, audit, deploy, verify — precisely because mainnet deployment is difficult to reverse and directly exposes the code to real value and real adversaries. Skipping the testing and audit stages to move faster is one of the most common and avoidable ways new contracts end up exploited.

Related articles

This article is for educational purposes only and is not financial advice. DeFi involves significant risk, including total loss of funds. Always do your own research.