> 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/foundry.md).

# Foundry

Use Foundry when you want Solidity tests and `forge` scripts. The Arcan Foundry library deploys the host contracts in the test: access list, executor, input verifier, and the decryption verifier. It also exposes encrypt and decrypt helpers so a test can act as a user.

## Base test

Inherit the Arcan test base. In `setUp`, call the base setup so the host contracts exist and `ArcanConfig` points at them.

```solidity
import { ArcanTest } from "@arcan/foundry/ArcanTest.sol";

contract TokenTest is ArcanTest {
    function setUp() public override {
        super.setUp();
    }
}
```

## Helpers

* Encrypt a plaintext as a given account and receive the external ciphertext plus the input proof.
* Call the contract under test.
* `decrypt` for an allowed user.
* `publicDecrypt` only after the contract has marked the handle publicly decryptable.

The helpers use the test coprocessor. They are not a shortcut that skips the access list. A decrypt for an account that was never granted the handle fails in the test the same way it fails in production.

## Scripts

A Forge script can deploy to a local Anvil node with the same host contracts. For Robinhood, the script uses the Arcan config for that host and an RPC URL you supply. Keep the deployer key out of the repository.

## What to assert

Compare decrypted plaintexts in the test, not handles, when you care about the amount. Compare handles when you care that storage changed. Never assert that a transaction log contains the user amount. It should not.


---

# 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/foundry.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.
