6

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!

3 Answers 3

2

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.

1
  • Forcing the transaction unfortunately resulted in it failing. I had no idea that EVM compatibility would affect simple smart contracts even at this level. I'll use Hardhat with the specific zkSync compiler instead!
    – Abel
    Jun 2, 2023 at 14:11
2
+50

You need to use hardhat-zksync-solc.

This is what the documentation says: To deploy a contract on Ethereum, a user sends a transaction to the zero address (0x000...000) with the data field of the transaction equal to the contract bytecode concatenated with the constructor parameters.

To deploy a contract on zkSync Era, a user calls the create function of the ContractDeployer system contract providing the hash of the contract to be published, as well as the constructor arguments. (Format: https://era.zksync.io/docs/dev/building-on-zksync/contracts/contract-deployment.html#format-of-bytecode-hash)

The documentation recommends Hardhat to deploy as it requires a different compiler https://era.zksync.io/docs/tools/hardhat/

Deploying contracts on zkSync Era is also possible via L1-L2 communication. https://era.zksync.io/docs/dev/developer-guides/bridging/l1-l2-interop.html

1

You can make use of atlaszk online IDE to run your deployment on zkSync instead of remix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.