ZKcandy Documentation
Interacting with Contracts
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 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:
Key | Value |
Chain Name | ZKcandy Mainnet |
RPC API Endpoint | https://rpc.zkcandy.io |
chainID | 320 |
Symbol | ETH |
Block Explorer |
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.
For ZKcandy Sepolia Testnet:
L1 Chain id | 1 |
L1 Chain name | Ethereum Mainnet |
L1 Chain key | mainnet |
L1 Chain RPC URL | https://eth.merkle.io |
L1 Chain explorer URL | https://etherscan.io |
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.