<100 subscribers
In this article we’ll cover how you can get the Remix IDE set up to deploy contracts to ZKcandy, particularly targeting ZKsync's EraVM which is native to ZKcandy.
The Remix IDE is maintained by the Ethereum Foundation while the ZKsync Plugin for Remix, which used to be maintained by Nethermind, is now maintained by Matter Labs. The Remix IDE is not affiliated with ZKcandy or the ZKcandy Foundation.
Remix is an Integrated Development Environment (IDE) maintained by the Ethereum Foundation. It functions as an easy method to develop, prototype, test and deploy smart contracts written in Solidity, Vyper and Yul to EVM blockchains. It has a built-in real-time compiler, linter and deployer, including test environments.
While the Remix IDE supports Solidity, Vyper and Yul, the ZKsync plugin for Remix only works with Solidity as it uses the zksolc
compiler. As such, this article will focus only on the deployment of smart contracts using Solidity.
Zkcandy is a Type-4 Zero Knowledge Rollup. This means that Zkcandy is a high-level EVM-compatible blockchain. However, ZKcandy is not EVM-equivalent (yet). Thus, smart contracts need specific tooling in order to be deployed to ZKcandy.
ZKcandy is also in the midst of implementing EVM Equivalence as part of the ZKsync V27 update. Once this is implemented, most of the current tooling, including Remix sans plugins, should work on ZKcandy.
Even with EVM equivalence, there are still a number of advantages in targeting the EraVM with smart contracts on ZKcandy. As the EraVM is native to ZKcandy, gas usage is more optimised with smart contracts. While gas fees on ZKcandy is much cheaper compared to L1 and is sometimes considered negligible, gas savings help builders who build for longevity save more over the lifespan of their smart contracts.
But for now, let's dive into using the Remix plugin!
The permalink for the Remix IDE is https://remix.ethereum.org.
Remix runs in most browsers as a web application but can also be used standalone on desktop. Downloads are available for Windows, macOS and Linux at https://github.com/remix-project-org/remix-desktop-insiders.
While the web version of Remix uses your browser storage for your project files, you can connect it to your computer’s local filesystem using remixd
. This is useful if you want to work with contracts from a local repository on your machine. More information on how to download and use remixd
can be found at https://remix-ide.readthedocs.io/en/latest/remixd.html.
The ZKsync Plugin for Remix can be installed by going to the bottom left of the screen and clicking on the plugin icon.
In the sidebar, search for the ZKsync plugin and activate it.
Write or import your contract in the editor. While the Remix IDE has limited support for Vyper and Yul, the ZKsync plugin in this post only supports Solidity at the time of writing.
When you are ready to compile your contract(s), make sure that the contract is selected and is the one that is open in your editor.
Now, open the ZKsync plugin in the sidebar by clicking on the ZKsync icon on the vertical toolbar on the left.
Please be patient as the ZKsync plugin may take a few seconds to load.
Once the plugin is loaded, the button to compile the active file in the editor should become active. If this button remains inactive or is unclickable, try closing the editor tab and reopening the file, then repeating the steps above or refreshing your browser/opening and closing your Remix desktop app.
The ZKsync Plugin does not provide continuous compilation for contracts.
If you contract or project involves importing libraries or other contracts, you may first need to flatten your contract first in order for the ZKsync plugin to properly compile it. To do this, right-click your contract file in the files panel and click “Flatten”. A new contract will be created in your files with _flattened
appended at the end of the filename. Select this contract and retry compiling.
The ZKsync Plugin may ask for write access to your files in the IDE and you may see a prompt like the one below:
You will need to grant this in order for the compiled contract artifacts to be stored and deployed.
Once you have your contract compiled, you can use the local VM within the ZKsync plugin to test your contract. When you are ready to proceed, use the dropdown on the top of the plugin sidebar to select a new environment, then click on “Wallet”.
The ZKsync Remote Devnet is often reset and may result in some issues with wallet and/or contract nonces. Use the ZKsync Era Sepolia testnet for testing if you encounter issues with the local or remote ZKsync Devnets
You will now see the Connect Wallet button. This button uses the WalletConnectV3 modal to connect most browser injected wallets, desktop wallets and mobile wallets to the plugin for contract deployment. As it is running within a plugin, your results may vary. In our testing this has worked with Metamask.
Select your preferred wallet from the modal and follow the instructions on your wallet interface to get connected with the plugin.
This plugin is being maintained by ZKsync. If you are having trouble with your wallet connecting to the plugin, consider opening an issue on its GitHub page at https://github.com/matter-labs/zksync-remix-plugin
Immediately after this step, you will see your wallet address in the place of the “Connect Wallet” button from the earlier step. Click on this.
Here, you will need to change the network to the ZKcandy Mainnet. Look for the corresponding icon for the ZKcandy Mainnet and click on it. You may have to approve a network change on your wallet interface so be sure to check your wallet to see if you need to approve this network change.
Now you can return to the main plugin interface and click on that “Deploy” button to deploy your contract to the ZKcandy Mainnet. If your contract accepts constructor arguments, you will need to populate these arguments in their respective fields above the "Deploy" button.
Your wallet will then prompt you to sign a message.
This will look unusual as unlike a regular transaction where you can enter parameters such as gas fees and gas limits. This is because ZK chains like ZKcandy can use the EIP-712 format for transactions which enable additional features such as paymaster gas sponsorship. Your gas fees and gas limit should be prepopulated by the IDE in this transaction.
Once you are ready, sign the transaction. The signature itself is gasless - but the transaction will still incur a small cost in ETH for deployment on the ZKcandy Sepolia Testnet.
If successful, you can now find your deployed contract address in the ZKsync Plugin sidebar under the Interact section. A button to copy the contract address will also be visible for you to copy the contract address.
That’s it! Your contract is now live on ZKcandy!
On the ZKsync plugin sidebar, you will see your contract under the Interact section.
You can now use your connected wallet to call functions on your contract using the buttons in this interface.
The next step is optional but would allow your contract and interactions with it to be more recognisable on the ZKcandy Block Explorer. It will also allow you to interact with your contract via the explorer using any connected wallet.
Navigate to https://explorer.zkcandy.io. Under the Tools section in the top navigation, click on "Smart Contract Verification".
You should see the following form.
Copy the contract address from Remix and paste it in the "Contract Address" section. Under "Compilation Target", make sure the switch is set to EraVM.
Under the "Compiler Type", select "Solidity (Single File)". The "Zksolc Version" can be found in the bottom left of the ZKsync Plugin on Remix. Select the one that matches what you see on Remix.
Under the "Solc Version", enable the checkbox on "Use zkVM solc". Then select the version of Solidity as populated in your contract's pragma
.
Select "Yes" for optimisation, then paste your entire flattened contract code into the section for the Solidity Contract Code.
If your contract has constructor arguments, you will need to paste them as ABI-encoded constructor arguments in the last field. You can use a tool like the one at https://abi.hashex.org/ to help you get this data.
After you're done, click on the "Verify Smart Contract" button. If successful, your contract should now be verified on the ZKcandy Block Explorer.
The ZKcandy Block Explorer will now support read and write functions on your contract within the explorer interface - and contract events can be viewed on your contract's page as well.
ZKcandy has already implemented most of the ZKsync V27 update - and EVM equivalence will be arriving very soon! Thanks to the great devs at Nethermind and Matter Labs, deploying to ZKcandy is now easier than before. It's only gonna get better from here. Follow us to find out when the upgrade goes online!
Follow our socials and join our community for the latest updates on ZKcandy.
X - https://twitter.com/ZKcandyHQ
Discord - https://discord.gg/ZKcandy
Medium - https://zkcandy.medium.com/
Telegram - https://t.me/ZKcandy
Daniel "St. Pinkie" Anthony