How to Build Smart Contracts on zkSync
zkSync Era lets you write smart contracts in Solidity and run them on a low-cost layer 2. Here is the toolchain, the build steps, and what differs from Ethereum.
On this page
Short answer
Smart contract development on zkSync Era means writing contracts in Solidity or Vyper and deploying them to a zero-knowledge rollup that settles on Ethereum. You use the same language and most of the same tooling as Ethereum, but a different compiler and deployer, because zkSync compiles contracts to its own bytecode.
What is zkSync Era?
zkSync Era is a layer 2 network built by Matter Labs that runs smart contracts on top of Ethereum and proves their results with zero-knowledge proofs. Transactions execute on the rollup, and a proof of the whole batch is checked on Ethereum, which is what gives the network its security.
For a developer, the important fact is that zkSync Era is compatible with the Ethereum Virtual Machine in practice: you write contracts in Solidity or Vyper, you use familiar tools such as Hardhat, and your users sign with ordinary wallets. The network is not a copy of Ethereum under the hood, so some details differ, but the day-to-day workflow will feel familiar to any Ethereum developer.
zkSync Era is the production network of the zkSync family. Its test network runs on Sepolia, which is where you should deploy first. The chain id for the main network is 324, and the test network is reached through the Sepolia testnet, so your deployment scripts need both an Ethereum endpoint and a zkSync endpoint. The basics are covered in what zkSync is.
Why build smart contracts on zkSync?
Teams build on zkSync for lower fees, faster confirmation and features that Ethereum does not offer natively. A rollup batches many transactions into one proof, so the cost of each transaction is shared across the batch. Confirmation is faster because the rollup produces blocks far more often than Ethereum mainnet.
The second reason is account abstraction. On zkSync Era, account abstraction is built into the protocol rather than added as an optional standard, so accounts can pay gas in tokens other than ETH, batch several actions into one transaction, or use social recovery. A contract that relies on these features works on zkSync without extra infrastructure.
The third reason is the user base that already lives on layer 2 networks. Users who moved to rollups expect low fees and fast apps, and they compare your app against other rollup apps rather than against Ethereum mainnet. If your app makes many small transactions, such as a game or a social app, that comparison matters more than raw security branding.
What tools do you need?
You need a Solidity setup, the zkSync compiler and deployer plugins, a test network with funds, and a way to run a local node for fast testing.
| Tool | What it does | When you use it |
|---|---|---|
| Hardhat | Project, compile and test runner | Every project |
| hardhat-zksync-solc | Compiles Solidity to zkSync bytecode | Every build |
| hardhat-zksync-deploy | Deploys contracts to zkSync | Every deploy |
| zksync-ethers | Wallet and provider library | Scripts and front end |
| zksync-cli | Local node and test environment | Local testing |
| Sepolia testnet | Public test network with faucet ETH | Before mainnet |
Hardhat is the most common choice because Matter Labs maintains official plugins for it. The compiler plugin replaces the standard Solidity compiler with zksolc, which produces the bytecode zkSync understands, and the deploy plugin handles the two-step deployment that zkSync requires. Foundry also supports zkSync, but the Hardhat path has the most documentation. The general contract workflow is explained in smart contract development.
How do you write and compile a contract for zkSync?
You write a contract for zkSync almost like any Solidity contract, then compile it with the zkSync compiler instead of the standard one. The differences are small but they matter, and they are easiest to learn on a small contract first.
Start by installing the plugins and adding them to your Hardhat configuration, with a zksolc section that sets the compiler version and settings. In the networks section, each zkSync network needs two URLs: one for the layer 1 network it settles on, and one for the zkSync node itself, plus a flag that marks the network as zkSync. Non-zkSync networks get the flag set to false.
Most Solidity code compiles unchanged. The main exceptions are inline assembly that touches the stack in ways the zkSync compiler does not support, and contracts that rely on Ethereum precompiles that behave differently on the rollup. The compiler reports these cases, so the practical rule is to compile early and fix the errors it shows rather than guessing. Keep contracts small and split logic across files so a compiler error points at one clear place.
How do you deploy a contract on zkSync?
You deploy a contract on zkSync by compiling it, getting test ETH, running a deploy script, and then verifying the contract so users can read it. The steps are the same shape as an Ethereum deploy, with a few zkSync-specific details.
- Set up the project. Create a Hardhat project, install the zkSync plugins, and add the network configuration for the Sepolia testnet.
- Write the contract. Keep it small for the first deploy, with one clear job and no external dependencies you have not tested.
- Compile with zksolc. Run the compile step and fix any compiler errors before moving on.
- Get test ETH. Take Sepolia ETH from a faucet and bridge it to the zkSync test network, or start a local node with the CLI for free testing.
- Write a deploy script. Use the deployer from the zkSync deploy plugin, which handles the extra deployment step the rollup requires.
- Deploy and verify. Run the script against the test network, check the address on the explorer, and verify the source so others can read it.
Test the full flow on the test network before touching mainnet, including the exact script you will run for the real deploy. A deploy that works locally can still fail on the test network if the wallet has too little ETH or the network configuration is wrong. Comparing zkSync with other rollups helps if you are still choosing a network.
What is different from building on Ethereum?
Several things differ from building on Ethereum, and most of them are consequences of the rollup design. The first is gas: fees on zkSync are usually much lower than on Ethereum mainnet, but they are metered differently, so a contract that is cheap on Ethereum can behave differently on the rollup. Measure gas on the test network instead of assuming it.
The second is account abstraction. Because it is native, your contract may be called by smart accounts that batch calls or pay gas in other tokens. That is useful, but it means you should not assume the caller is a normal wallet address, and you should test with a smart account before launch.
The third is the deployment flow itself. zkSync deploys contracts in two steps, and the deployer plugin hides that detail, but you will see it in gas costs and in the explorer. There are also system contracts on the network that handle functions such as bridging, and your contract interacts with them when it moves assets between layers. None of this blocks a normal app, but each difference is worth one test before launch.
Example (hypothetical): a small token contract moves to zkSync
Example (hypothetical): a team has a simple token contract on Ethereum mainnet. It has 2,000 holders and handles about 400 transfers a day. On mainnet, each transfer costs the user a noticeable fee, so small transfers have stopped happening.
The team copies the contract into a Hardhat project with the zkSync plugins and compiles it. The first compile fails on one inline assembly block, which they replace with plain Solidity in an afternoon. The second compile passes, and they deploy to the Sepolia testnet.
They run 400 test transfers through a script and check the results on the explorer. All 400 succeed, and the team then deploys the same contract to mainnet and bridges the token supply. The whole move takes three working days, of which two are testing. The lesson the team records is that the compile step, not the deploy step, is where the work hides.
What are the common mistakes?
The most common mistakes on zkSync are assuming Ethereum code works unchanged, skipping the test network, and forgetting that gas works differently on a rollup.
- Compiling late. Writing a large contract before the first compile means the compiler errors arrive all at once. Compile after every small change.
- Skipping the test network. A deploy that works on a local node can fail on the public test network, so the test network step is not optional.
- Assuming gas is free. Fees are lower than on mainnet, but they still exist, and a loop that is cheap on Ethereum can cost more on a rollup.
- Ignoring account abstraction. Smart accounts can call your contract in ways a normal wallet cannot, so test with one before launch.
- Deploying with a main wallet. Use a dedicated deploy wallet with only the funds it needs, and keep its key separate from personal wallets.
- No verification. An unverified contract makes users and auditors suspicious, so verify the source on the explorer after every deploy.
Key takeaways
- zkSync Era runs Solidity contracts on a zero-knowledge rollup that settles on Ethereum
- The Hardhat plugins handle the compiler and the two-step deploy flow
- Account abstraction is native, so smart accounts can pay gas in other tokens
- Gas is metered differently on a rollup, so measure it on the test network
- Compile early and deploy to Sepolia before mainnet
Frequently asked questions
Is zkSync Era compatible with Solidity?
Yes. You write contracts in Solidity or Vyper, and zkSync Era supports the language features most projects use. The difference is the compiler: contracts are compiled with zksolc to bytecode the rollup understands. A small amount of code, mostly inline assembly, may need rewriting, and the compiler reports those cases.
Do I need to learn a new language for zkSync?
No. Solidity is the main language, and Vyper is also supported. What you need to learn is the toolchain: the Hardhat plugins, the two-endpoint network configuration, and the deployer. A developer who already writes Solidity can usually deploy a first contract to the test network within a day.
What is the difference between zkSync Era and zkSync Lite?
zkSync Era is the full network with general smart contracts, while zkSync Lite is an earlier, simpler network that only supports payments and token transfers. New projects should build on Era, since Lite does not run arbitrary contracts. The two networks have different addresses and tooling, so check which one a guide refers to.
How much does it cost to deploy on zkSync?
Deployment costs a fee in ETH, and it is usually far lower than deploying the same contract on Ethereum mainnet. The exact cost depends on the size of the contract and the current network load. Deploy to the Sepolia testnet first, where the fee is paid in test ETH, and check the real cost there before mainnet.
Can I move an existing Ethereum contract to zkSync?
In most cases, yes. Copy the source into a zkSync Hardhat project, compile it with zksolc, fix any compiler errors, and deploy to the test network. Contracts that use inline assembly or unusual precompiles need the most work. Test the full behaviour on the test network, including any interaction with other contracts, before mainnet.
Where can I get help building on zkSync?
The official zkSync documentation covers the plugins, the CLI and the network configuration in detail, and the community forum answers toolchain questions. For a production build, a smart contract development team can handle the setup, testing and audit preparation so your team focuses on the product itself.