# Contract Deployment and Verification

## Contract Deployment <a href="#contract-deployment" id="contract-deployment"></a>

Like zkSync Era, Cronos zkEVM recommends the use of:

* Hardhat for smart contract development
* Node Typescript with the ethers library for backend and frontend development

While the [zkSync docs](https://docs.zksync.io/) are the most comprehensive and up to date source of information, you can also refer to [this linked repository](https://github.com/kentimsit/cronos-zkevm-hardhat-boilerplate), created especially for Cronos zkEVM Chain, which shows how to read the blockchain, write on the blockchain, and develop smart contracts:

* Refer to the [README.md](https://github.com/kentimsit/cronos-zkevm-hardhat-boilerplate/blob/main/README.md) file for a list of frequently used commands.
* The typical network configuration parameters are shown in the [hardhat.config.ts](https://github.com/kentimsit/cronos-zkevm-hardhat-boilerplate/blob/main/hardhat.config.ts) file.
* The scripts directories contain some useful examples of scripts and functions that you may need to execute calls and transactions.

## Contract Verification <a href="#contract-verification" id="contract-verification"></a>

In order to enable users and fellow developers to do their own research, it is imperative that you publish your smart contract code on Cronos zkEVM Explorer.&#x20;

The Cronos zkEVM Explorer supports smart contract verification either through the web interface or programmatically via Hardhat (**we recommend to use Hardhat**).

#### **Contract Verification Via Hardhat:**

Cronos zkEVM is supported by Hardhat out of the box, to verify contract using Hardhat, we will need:&#x20;

1. **Configure the network parameters in `hardhat.config.js`**, referring to this [guide](https://explorer-api-doc.zkevm.cronos.org/mainnet/index.html#post-https-//explorer-api.zkevm.cronos.org/api/v1/contract/verify/hardhat).  As an example, the `verifyURL` for mainnet should be set as&#x20;

{% tabs %}
{% tab title="Mainnet" %}

```
verifyURL: "https://explorer-api.zkevm.cronos.org/api/v1/contract/verify/hardhat?apikey={apikey}"
```

{% endtab %}

{% tab title="Testnet" %}

```
verifyURL: "https://explorer-api.testnet.zkevm.cronos.org/api/v1/contract/verify/hardhat?apikey={apikey}"
```

{% endtab %}
{% endtabs %}

2. **A "Developers Portal" API key**, refer to below guides on how to register and obtain one.

* Cronos zkEVM Mainnet: <https://explorer-api-doc.zkevm.cronos.org/mainnet/index.html#overview>&#x20;
* Cronos zkEVM Testnet: <https://explorer-api-doc.zkevm.cronos.org/testnet/index.html#overview>

**We can also refer to the example provided in** [**this boilerplate repository**](https://github.com/kentimsit/cronos-zkevm-hardhat-boilerplate/blob/main/README.md#compilation-and-deployment)**.**

{% hint style="warning" %}
Note: During the contract verification Via Hardhat **-** Please install and use **`@matterlabs/hardhat-zksync-verify`** version 1.7.1+ instead of *hardhat-etherscan*
{% endhint %}

After the contract verification is complete, the [Cronos zkEVM Explorer](https://explorer.zkevm.cronos.org/) will display details about your smart contract code.

#### **Contract Verification Via Explorer interface:**

For verification via the web interface, visit the following URLs:

* Mainnet: <https://explorer.zkevm.cronos.org/verifyContract>
* Testnet: <https://explorer.zkevm.cronos.org/testnet/verifyContract>

{% hint style="warning" %}
Note that when using contract verification via the explorer interface, `Standard-Json-Input` method is required. Reference for the JSON file format:<https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description>
{% endhint %}

***

## Important note about tokens

If you are planning to deploy a ERC20 token on Cronos zkEVM, keep in mind that there are two ways to do this:

* Deploy directly on the L2: this approach is simple to implement, but in that case, the ERC20 token won’t be supported natively by the hyperbridge between L1 and L2, and between hyperchains. A custom bridge will be required to withdraw or transfer tokens from the L2.
* Deploy first on the L1, then deposit to the L2: this approach requires two steps, but its advantage is that the tokens will be natively supported by the hyperbridge between L1 and L2. They can be deposited into the L2, or withdrawn from the L2, at will. When the first token is deposited from L1 to L2, the hyberbridge automatically creates a ERC20 smart contract on L2, which is the representation of the L1 token on the L2.

After deploying your smart contract, you will need to publish and verify its code in the block explorer:

* If you have deployed directly on the L2, the deployment script included in the boilerplate project performs the contract code publication and verification automatically.
* If you deploy first on the L1 (Ethereum Sepolia), you can publish and verify the contract code on the Etherscan Sepolia block explorer as usual. With respect to publishing and verifying the code of the L2 smart contract created by the hyperbridge, this is not yet supported.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-zkevm.cronos.org/for-developers/develop-smart-contracts-and-dapps/contract-deployment-and-verification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
