ZKcandy Documentation
Interacting with Contracts
As of 12 February 2025, the contract verification endpoint for both Testnet and Mainnet are not fully functional. Deployed contracts should work properly. To interact with a deployed contract, use the
zksync-cli
as documented on this page.We advise developers to delay contract deployment until the verification endpoint is up and running for better transparency on ZKcandy.
Using the ZKcandy Block Explorer
There are a number of ways in which you can interact with your smart contract. If your contract has been verified on the ZKcandy Block Explorer, you can proceed to the contract page by searching for the contract address and then clicking on Contract tab followed by the Read or Write buttons to call functions on your contract.
Using zksync-cli
The contract commands available in
zksync-cli
also provide an excellent way to interact with your contract. You will need to add ZKcandy Sepolia as a network using the steps below:Step 1 - Install zksync-cli
Install with the following command:
yarn add zksync-cli
Step 2 - Add ZKcandy Sepolia to network configuration
Run the following command to interactively add ZKcandy to your list of networks in your development environment for hardhat to work with. This list is separate from the list in your
hardhat.config.ts
file:yarn zksync-cli config chains
When the menu appears, press Enter to add a new chain. Key in the following information:
For ZKcandy Sepolia Testnet:
Chain id | 302 |
Chain name | ZKcandy Sepolia |
Chain key | zkcandy-sepolia |
Chain RPC URL | https://sepolia.rpc.zkcandy.io |
Chain explorer URL | https://sepolia.explorer.zkcandy.io |
In the next menu you will be prompted to respond to whether this chain is connected to an L1. Select
Yes - add L1 chain info
and then key in the following information:Make sure you connect the appropriate L1 for your configuration. If you are adding the ZKcandy Mainnet, ensure that you are adding the Ethereum mainnet as your L1. Likewise if you are adding the ZKcandy Sepolia Testnet, ensure that you are adding the Ethereum Sepolia Testnet (usually known as just ‘Sepolia’) as your L1.
For ZKcandy Sepolia Testnet:
L1 Chain id | 11155111 |
L1 Chain name | Sepolia |
L1 Chain key | sepolia |
L1 Chain RPC URL | |
L1 Chain explorer URL |
After keying in the above information, you will now be ready to interact with contracts on ZKcandy through your command line provided that you know the method signature of the function you wish to call.
Using
Entering your private key into a terminal interface comes with some risk. Do not use this option to interact with your contract if you do not trust the computer you are running it from (e.g. shared machines, public/school computers, cloud IDEs etc).
zksync-cli contract write
will prompt you to enter the private key of the wallet you wish to use. Ensure you have this key on-hand.Entering your private key into a terminal interface comes with some risk. Do not use this option to interact with your contract if you do not trust the computer you are running it from (e.g. shared machines, public/school computers, cloud IDEs etc).
The full documentation on
zksync-cli contract
can be found on the official zksync-cli docs here.