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 Sepolia Testnet 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 the ZKcandy Sepolia network:

yarn zksync-cli config chains

When the menu appears, press Enter to add a new chain. Key in the following information:

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

L1 Chain id 11155111
L1 Chain name Sepolia
L1 Chain key sepolia
L1 Chain RPC URL https://rpc.sepolia.org
L1 Chain explorer URL https://sepolia.etherscan.io

After keying in the above information, you will now be ready to interact with contracts on the ZKcandy Sepolia Testnet through your command line provided that you know the method signature of the function you wish to call.

<aside> <img src="/icons/star_lightgray.svg" alt="/icons/star_lightgray.svg" width="40px" /> 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).

</aside>

The full documentation on zksync-cli contract can be found on the official zksync-cli docs at the following link:

https://docs.zksync.io/build/tooling/zksync-cli/zksync-cli-contract

← Previous

Deploying to the ZKcandy Testnet

Next →

Brand Assets

On this page