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

# Hardhat

Use Hardhat when the contract tests and the app share one repository. The Arcan Hardhat plugin starts a local host and a local coprocessor, deploys the access list and the executor, and gives the SDK a way to encrypt fixtures.

## Project layout

```
contracts/      Solidity, inheriting ArcanConfig
test/           Hardhat tests
sdk usage       @arcan/sdk encrypts the inputs in the tests
```

Install `@arcan/solidity` and `@arcan/sdk`. Point Hardhat at the Arcan plugin so `ArcanConfig` resolves to the local host contracts during tests.

## A test flow

1. Deploy the contract. The plugin has already deployed the host.
2. Create an SDK instance against the local node.
3. Encrypt the amount with the test account.
4. Send `confidentialTransfer` with the ciphertext and the input proof.
5. Read `confidentialBalanceOf`. Assert that the return value is a handle, not the amount.
6. User-decrypt as the recipient and assert the plaintext. Decrypt as a third account and assert that it fails.

## Deploying

A deploy script should inherit addresses from `ArcanConfig` for Robinhood. Do not hard-code another chain's executor into the artifact.

The script sends the contract creation transaction to the Robinhood RPC you configure. The FHE library inside the contract still records operations for the coprocessors. Deployment does not turn Robinhood into an FHE computer.

## Debugging

If `fromExternal` reverts, the input proof does not match the user, the contract, or the ciphertext. Rebuild the input with the SDK against the same contract address.

If a later `FHE.add` reverts on permissions, the new handle was not passed to `allowThis` or `allow`.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.arcan.finance/development/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 `build a script that syncs our docs to a CMS` 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.
