> For the complete documentation index, see [llms.txt](https://docs.coti.io/coti-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coti.io/coti-documentation/build-on-coti/tools/hardhat.md).

# Hardhat

The easiest way to get started with writing smart contracts on COTI is to clone the [**COTI Hardhat Template**](https://github.com/coti-io/coti-hardhat-template). This template is a simple [**Hardhat**](https://hardhat.org/) project that includes all the configurations and packages needed to connect to the Testnet and integrate COTI's privacy features into your own smart contracts.

{% hint style="info" %}
Since the local Hardhat network does not include the precompiled contracts needed for computations on private data types, the **only** way to test contracts that use these features is by running your test scripts on the COTI Testnet.
{% endhint %}

Let's start by cloning the repository:

```bash
git clone https://github.com/coti-io/coti-hardhat-template
```

Before we can continue with exploring the repository, we have to install the dependencies:

```bash
npm install
```

The repository includes a simple privacy-enabled smart contract (`PrivateStorage.sol`) which, as the name suggests, accepts encrypted inputs and stores them on-chain using the user's [AES encryption key](/coti-documentation/how-coti-works/advanced-topics/aes-keys.md). There is also a short test suite included in the template.

To run the test suite, execute the following command in your terminal:

```bash
npx hardhat test
```

On your first time running the test suite, you will see the following message printed to the console:

```bash
1) PrivateStorage
       Deployment
         Should set the value of the encrypted number:
     Error: Created new random accounts <ACCCOUNT_ADDRESS>. Please use faucet to fund it.
```

To fund the newly created account, head over to the [**faucet**](https://faucet.coti.io/) and send a message to the both in the following format:

```bash
testnet <ACCCOUNT_ADDRESS>
```

Now that you have funded your account, you can run the test suite again:

```bash
npx hardhat test
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coti.io/coti-documentation/build-on-coti/tools/hardhat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
