# Circuit Functions

#### `witness`

This function creates a `CircuitValue` that can change between different runs of the circuit (think of it as a JavaScript `let`). For example, if you wanted to create a circuit that checks if a user's balance is above some threshold, you would make the user's address a witness so that the circuit could be used to prove that *any* address's balance is above the threshold.

```typescript
/**
 * Creates a circuit variable from a number, bigint, or string.
 *
 * @param a - The raw circuit input.
 * @returns The witness cell.
 */
witness: (a: number | bigint | string) => CircuitValue;
```

#### `constant`

This function creates a `CircuitValue` that must be the same every time you run your circuit (think of it as JavaScript `const`). For example, from the example above, you could make the threshold a constant to enforce that every time the circuit is run, the same threshold is used.

```typescript
/**
 * Creates a circuit constant from a number, bigint, or string.
 *
 * @param a - The raw circuit input.
 * @returns The constant cell.
 */
constant: (a: number | bigint | string) => CircuitValue;
```

#### `log`

The `log(...)` function is used to debug the value of a `CircuitValue` or a `CircuitValue256` (or some array of them). This is useful for debugging and checking that the values inside the circuit are what you would expect.

<pre class="language-typescript"><code class="lang-typescript"><strong>/**
</strong> * Logs the provided *circuit* values to the console. 
 * Use `console.log` for normal logging.
 *
 * @param args - The values to log (can be `CircuitValue`s or `CircuitValue256`s).
 */
log: (...args: (CircuitValue | CircuitValue256)[]) => void;
</code></pre>

#### `addToCallback`

This function is used to add a values to the data which is passed to your contract when your query is fulfilled. You can call `addToCallback` a maximum of 128 times inside AxiomREPL. See [handling-axiom-callbacks](https://intrinsic-1.gitbook.io/axiomv2-sdk/developers/handling-axiom-callbacks "mention") for more info on setting up your contract to receive the the data you pass to `addToCallback`.&#x20;

<pre class="language-typescript"><code class="lang-typescript">/**
 * Adds a circuit value to the callback. 
 * Values passed to this function will be passed to your
<strong> * callback client contract on-chain by Axiom.
</strong> *
 * @param a - The circuit value to add to the callback.
 */
addToCallback: (a: CircuitValue | CircuitValue256) => void;
</code></pre>


---

# 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://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiomrepl-reference/circuit-functions.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.
