Interacting with your Smart Contract

Using the ZKcandy Sepolia 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 Mainnet:

mnx
Chain id320
Chain nameZKcandy Mainnet
Chain keyzkcandy-mainnet
Chain RPC URLhttps://rpc.zkcandy.io
Chain explorer URLhttps://explorer.zkcandy.io

For ZKcandy Sepolia Testnet:

tnx
Chain id302
Chain nameZKcandy Sepolia
Chain keyzkcandy-sepolia
Chain RPC URLhttps://sepolia.rpc.zkcandy.io
Chain explorer URLhttps://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 Mainnet:

mnx
L1 Chain id1
L1 Chain nameEthereum
L1 Chain keymainnet
L1 Chain RPC URLhttps://eth.nodeconnect.org
L1 Chain explorer URLhttps://etherscan.io

For ZKcandy Sepolia Testnet:

tnx
L1 Chain id11155111
L1 Chain nameSepolia
L1 Chain keysepolia
L1 Chain RPC URLhttps://rpc.sepolia.org
L1 Chain explorer URLhttps://sepolia.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 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.