# CircuitContext

> For the complete documentation index, see [llms.txt](https://docs.midnight.network/llms.txt)

[**@midnight-ntwrk/compact-runtime v0.21.0**](https://docs.midnight.network/api-reference/compact-runtime.md)

***

[@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals.md) / CircuitContext

# Interface: CircuitContext\<PS>

The external information accessible from within a Compact circuit call

## Type Parameters[​](#type-parameters "Direct link to Type Parameters")

### PS[​](#ps "Direct link to PS")

`PS` = `any`

## Properties[​](#properties "Direct link to Properties")

### activeContracts?[​](#activecontracts "Direct link to activeContracts?")

```
optional activeContracts: Set<string>;
```

The contract addresses currently executing: the entry contract, plus every callee whose call has not returned. Shared by reference across the call tree, so [crossContractCall](https://docs.midnight.network/api-reference/compact-runtime/functions/crossContractCall.md) can reject re-entry (`A -> A`, `A -> B -> A`) from any depth.

***

### callContext[​](#callcontext "Direct link to callContext")

```
callContext: CallContext<PS>;
```

The context for the current call.

***

### callProofDataTrace[​](#callproofdatatrace "Direct link to callProofDataTrace")

```
callProofDataTrace: CallProofDataTrace;
```

Sequence of calls made during the execution of the circuit (including the call for the root circuit).

***

### contractStates?[​](#contractstates "Direct link to contractStates?")

```
optional contractStates: Record<string, ContractState>;
```

The deployed state of every cross-contract callee, keyed by address and filled on first resolution. The cached query context keeps only ledger data, so this is where a callee's verifier keys are read from, for any of its circuits and on every call. The entry contract is always on the call stack, so the re-entrancy guard keeps it out of callee position and it never appears here.

***

### costModel[​](#costmodel "Direct link to costModel")

```
costModel: CostModel;
```

The cost model to use for the execution.

***

### events[​](#events "Direct link to events")

```
events: LogEvent[];
```

Events the VM emitted from `log` operations, each tagged with the contract that emitted it. One list for the whole call tree, threaded like [callProofDataTrace](#callproofdatatrace).

***

### gasCosts[​](#gascosts "Direct link to gasCosts")

```
gasCosts: Record<ContractAddress, RunningCost>;
```

The current gas costs for every contract in the call tree.

***

### gasLimit?[​](#gaslimit "Direct link to gasLimit?")

```
optional gasLimit: RunningCost;
```

The gas limit for this circuit.

***

### queryContexts[​](#querycontexts "Direct link to queryContexts")

```
queryContexts: Record<ContractAddress, QueryContext>;
```

The current query context of every contract in the call tree.

***

### stateProvider?[​](#stateprovider "Direct link to stateProvider?")

```
optional stateProvider: ContractStateProvider;
```

Can fetch the current state of a contract from the blockchain.

***

### zswapLocalStates[​](#zswaplocalstates "Direct link to zswapLocalStates")

```
zswapLocalStates: Record<ContractAddress, EncodedZswapLocalState>;
```

The current Zswap local state of every contract in the call tree, keyed like [queryContexts](#querycontexts). Each contract has its own `currentIndex`, `inputs` and `outputs`; only the submitter's `coinPublicKey` is shared, since one wallet pays for the transaction.
