zkSync Deployment – How to Deploy Smart Contract on zkSync Era Testnet Using Remix and MetaMask

metamaskremixzksync

I want to use the zkSync Era Testnet to do some testing with different smart contracts. I am using Remix with MetaMask as the injected provider to deploy the contract on the testnet. The contract compiles just fine, and I have been able to use this method to deploy the exact same contracts on the Polygon zkEVM Testnet. However, when I have the zkSync Era Testnet selected in MetaMask and try to deploy the contract, I get the following error message (see picture):

Gas estimation failed. Failed to serialize transaction:
toAddressIsNull","id":4712902792361366

Failed to serialize transaction: toAddressIsNull","id":4712902792361366

This is the smart contract I'm trying to deploy:

pragma solidity ^0.8.7;
// SPDX-License-Identifier: MIT

contract Dummy {
    address public owner;

    constructor() {
        owner = msg.sender;
    }
}

Although, ultimately I would ofcourse deploy different smart contracts, but even this dummy contract won't deploy.
I have the zkSync Era Testnet configured in MetaMask with this RPC URL (see picture):

https://testnet.era.zksync.dev

zkSyncTestnetConfig

The configuration works fine on MetaMask, and I have some ETH on this network. I have also tried to change the RPC URL to these other ones which I found online, but that didn't change the error:

https://zksync2-testnet.zksync.dev

https://zksync-era-testnet.rpc.thirdweb.com

It is only the zkSync Era Testnet that I have encountered so far which gives these errors, I have been able to deploy smart contracts on other testnets just fine. Any help or suggestions as to what I could try / change would be greatly appreciated!

Best Answer

Have you tried forcing the transaction? Unfortunately, zkSync is EVM compatible, not equivalent, (more on this distinction here) so you need our specific compiler to compile your contract. See here:

https://era.zksync.io/docs/dev/building-on-zksync/hello-world.html

You’ll need to be familiar with Hardhat, but the tutorial walks you through in a step by step fashion.

Related Topic