Axiom Circuit Reference
A client circuit is defined as an async function f: (inputs: T) => Promise<void>
where you must specify the input type T
of your circuit for type safety. You can name the circuit function anything you want.
Circuit Inputs
The circuit input should consist of all inputs to your circuit that are variable and change with each run of the circuit. The circuit input type can be any interface where the primitive value types are either CircuitValue
or CircuitValue256
. These are protected classes for ZK-specific usage. For example, Array<CircuitValue>
is an allowed type, while Array<number>
is not. Constant values that do not change should be included directly inside the circuit function itself.
Input Parsing
When you prove
a circuit, the inputs will be provided in a JSON or a Typescript interface. This input type should have the same structure as your circuit input type T
but the primitive types can be number | string | bigint
. This type is auto-parsed into the circuit input type T
. For example, Array<number>
will be parsed into Array<CircuitValue>
.
There will be a run-time error if you provide an input that cannot be parsed to the circuit input type (for example if you try to parse a 256 bit bigint
into CircuitValue
).
Circuit Outputs
Within the circuit function, you can specify what values to add to the output via the addToCallback
function. This takes either CircuitValue
or CircuitValue256
. Each value is cast to uint256
and then to bytes32
and added to an array axiomResults: bytes32[]
. These results are what your callback smart contract will receive when your query is successfully fulfilled.
CircuitValue
and CircuitValue256
are always interpreted as uint
types. This means when they are added to axiomResults
, they are always left-padded with 0s to uint256
and then cast to bytes32
.
See the following pages to learn about the two types available inside a circuit, CircuitValue
and CircuitValue256
, and to see a complete listing of functions available to call inside a client circuit. If you have installed the Client SDK locally in your project as an npm dependency, these functions should be detectable by your IDE: we have made these functions a global library for access within the circuit code.
📄️ Data Types for Circuits
In an Axiom client circuit, it is important to distinguish between values that should be constant in the circuit regardless of what inputs it is given, and values that are variable and depend on the inputs to the circuit. We use different data types to distinguish these notions. In particular we have the primitive types ConstantValue, CircuitValue, and CircuitValue256. All circuit inputs must be built from CircuitValue and CircuitValue256 types to delineate that they are variable and may change with each new proof.
📄️ ZK Primitives
ZK primitives validated directly in the client circuit
📄️ System Functions
Commonly used system functions
🗃️ Axiom Subqueries
6 items