modules
o1js / Modules
o1js
Table of contents
Namespaces
Enumerations
Classes
- AccountUpdate
- Bool
- Character
- Circuit
- CircuitString
- CircuitValue
- Field
- Group
- Int64
- Keypair
- Ledger
- MerkleMap
- MerkleMapWitness
- MerkleTree
- Nullifier
- PrivateKey
- Proof
- Scalar
- SelfProof
- Sign
- Signature
- SmartContract
- Token
- TokenSymbol
- UInt32
- UInt64
- VerificationKey
Interfaces
Type Aliases
- Bool
- BoolVar
- Cache
- CacheHeader
- ConstantField
- DeployArgs
- Empty
- FeatureFlags
- Field
- FieldConst
- FieldVar
- FlexibleProvable
- FlexibleProvablePure
- Gate
- GateType
- Group
- InferProvable
- JsonGate
- JsonProof
- MlFeatureFlags
- MlPublicKey
- MlPublicKeyVar
- Provable
- ProvableExtended
- Reducer
- State
- Struct
- TransactionStatus
- Undefined
- Void
- ZkappPublicInput
Variables
- Cache
- Empty
- FieldConst
- FieldVar
- Gadgets
- Permissions
- Pickles
- Poseidon
- Provable
- Snarky
- Test
- TokenId
- Undefined
- Void
- ZkappPublicInput
- isReady
Functions
- Account
- Bool
- Field
- Group
- MerkleWitness
- Reducer
- State
- Struct
- ZkProgram
- addCachedAccount
- arrayProp
- checkZkappTransaction
- circuitMain
- declareMethods
- declareState
- fetchAccount
- fetchEvents
- fetchLastBlock
- fetchTransactionStatus
- getWasm
- isBool
- isField
- matrixProp
- method
- prop
- provable
- provablePure
- public_
- readVarMessage
- scaleShifted
- sendZkapp
- setArchiveGraphqlEndpoint
- setGraphqlEndpoint
- setGraphqlEndpoints
- shutdown
- state
- toConstantField
- toFp
- verify
- withMessage
Type Aliases
Bool
Ƭ Bool: Bool
Defined in
BoolVar
Ƭ BoolVar: FieldVar
Defined in
Cache
Ƭ Cache: Object
Interface for storing and retrieving values, for caching.
read()
and write()
can just throw errors on failure.
The data that will be passed to the cache for writing is exhaustively described by the CacheHeader type. It represents one of the following:
- The SRS. This is a deterministic lists of curve points (one per curve) that needs to be generated just once, to be used for polynomial commitments.
- Lagrange basis commitments. Similar to the SRS, this will be created once for every power-of-2 circuit size.
- Prover and verifier keys for every compiled circuit.
Per smart contract or ZkProgram, several different keys are created:
- a step prover key (
step-pk
) and verification key (step-vk
) for every method. - a wrap prover key (
wrap-pk
) and verification key (wrap-vk
) for the entire contract.
Type declaration
Name | Type | Description |
---|---|---|
canWrite | boolean | Indicates whether the cache is writable. |
debug? | boolean | If debug is toggled, read() and write() errors are logged to the console. By default, cache errors are silent, because they don't necessarily represent an error condition, but could just be a cache miss, or file system permissions incompatible with writing data. |
read | (header : CacheHeader ) => undefined | Uint8Array | Read a value from the cache. |
write | (header : CacheHeader , value : Uint8Array ) => void | Write a value to the cache. |
Defined in
CacheHeader
Ƭ CacheHeader: StepKeyHeader
<"step-pk"
> | StepKeyHeader
<"step-vk"
> | WrapKeyHeader
<"wrap-pk"
> | WrapKeyHeader
<"wrap-vk"
> | PlainHeader
<"srs"
> | PlainHeader
<"lagrange-basis"
> & CommonHeader
A header that is passed to the caching layer, to support rich caching strategies.
Both uniqueId
and programId
can safely be used as a file path.
Defined in
ConstantField
Ƭ ConstantField: Field
& { value
: ConstantFieldVar
}
Defined in
DeployArgs
Ƭ DeployArgs: { verificationKey?
: { data
: string
; hash
: string
| Field
} ; zkappKey?
: PrivateKey
} | undefined
Defined in
Empty
Ƭ Empty: Undefined
Defined in
FeatureFlags
Ƭ FeatureFlags: Object
Type declaration
Name | Type |
---|---|
foreignFieldAdd | boolean |
foreignFieldMul | boolean |
lookup | boolean |
rangeCheck0 | boolean |
rangeCheck1 | boolean |
rot | boolean |
runtimeTables | boolean |
xor | boolean |
Defined in
Field
Ƭ Field: Field
Defined in
FieldConst
Ƭ FieldConst: [0
, bigint
]
Defined in
FieldVar
Ƭ FieldVar: [Constant
, FieldConst
] | [Var
, number
] | [Add
, FieldVar
, FieldVar
] | [Scale
, FieldConst
, FieldVar
]
FieldVar
is the core data type in snarky. It is eqivalent to Cvar.t
in OCaml.
It represents a field element that is part of provable code - either a constant or a variable.
Variables end up filling the witness columns of a constraint system. Think of a variable as a value that has to be provided by the prover, and that has to satisfy all the constraints it is involved in.
Constants end up being hard-coded into the constraint system as gate coefficients. Think of a constant as a value that is known publicly, at compile time, and that defines the constraint system.
Both constants and variables can be combined into an AST using the Add and Scale combinators.
Defined in
FlexibleProvable
Ƭ FlexibleProvable<T
>: Provable
<T
> | Struct
<T
>
Type parameters
Name |
---|
T |
Defined in
FlexibleProvablePure
Ƭ FlexibleProvablePure<T
>: ProvablePure
<T
> | StructPure
<T
>
Type parameters
Name |
---|
T |
Defined in
Gate
Ƭ Gate: Object
Type declaration
Name | Type |
---|---|
coeffs | string [] |
type | GateType |
wires | { col : number ; row : number }[] |
Defined in
GateType
Ƭ GateType: "Zero"
| "Generic"
| "Poseidon"
| "CompleteAdd"
| "VarbaseMul"
| "EndoMul"
| "EndoMulScalar"
| "Lookup"
| "RangeCheck0"
| "RangeCheck1"
| "ForeignFieldAdd"
| "ForeignFieldMul"
| "Xor16"
| "Rot64"
Defined in
Group
Ƭ Group: Group
Defined in
InferProvable
Ƭ InferProvable<A
>: A
extends Constructor
<infer U> ? A
extends Provable
<U
> ? U
: A
extends Struct
<U
> ? U
: InferProvableBase
<A
> : InferProvableBase
<A
>
Type parameters
Name |
---|
A |
Defined in
bindings/lib/provable-snarky.ts:274
JsonGate
Ƭ JsonGate: Object
Type declaration
Name | Type |
---|---|
coeffs | string [] |
typ | GateType |
wires | { col : number ; row : number }[] |
Defined in
JsonProof
Ƭ JsonProof: Object
Type declaration
Name | Type |
---|---|
maxProofsVerified | 0 | 1 | 2 |
proof | string |
publicInput | string [] |
publicOutput | string [] |
Defined in
MlFeatureFlags
Ƭ MlFeatureFlags: [_: 0, rangeCheck0: MlBool, rangeCheck1: MlBool, foreignFieldAdd: MlBool, foreignFieldMul: MlBool, xor: MlBool, rot: MlBool, lookup: MlBool, runtimeTables: MlBool]
Defined in
MlPublicKey
Ƭ MlPublicKey: [_: 0, x: FieldConst, isOdd: MlBool]
Defined in
MlPublicKeyVar
Ƭ MlPublicKeyVar: [_: 0, x: FieldVar, isOdd: BoolVar]
Defined in
Provable
Ƭ Provable<T
>: Provable
<T
>
Provable<T>
is the general circuit type interface. It describes how a type T
is made up of field elements and auxiliary (non-field element) data.
You will find this as the required input type in a few places in o1js. One convenient way to create a Provable<T>
is using Struct
.
Type parameters
Name |
---|
T |
Defined in
ProvableExtended
Ƭ ProvableExtended<T
, TJson
>: Provable
<T
> & ProvableExtension
<T
, TJson
>
Type parameters
Name | Type |
---|---|
T | T |
TJson | any |
Defined in
Reducer
Ƭ Reducer<Action
>: Object
Type parameters
Name |
---|
Action |
Type declaration
Name | Type |
---|---|
actionType | FlexibleProvablePure <Action > |
Defined in
State
Ƭ State<A
>: Object
Gettable and settable state that can be checked for equality.
Type parameters
Name |
---|
A |
Type declaration
Name | Type |
---|---|
assertEquals | (a : A ) => void |
assertNothing | () => void |
fetch | () => Promise <undefined | A > |
fromAppState | (appState : Field []) => A |
get | () => A |
getAndAssertEquals | () => A |
set | (a : A ) => void |
Defined in
Struct
Ƭ Struct<T
>: ProvableExtended
<NonMethods
<T
>> & Constructor
<T
> & { _isStruct
: true
}
Type parameters
Name |
---|
T |
Defined in
TransactionStatus
Ƭ TransactionStatus: "INCLUDED"
| "PENDING"
| "UNKNOWN"
INCLUDED: A transaction that is on the longest chain
PENDING: A transaction either in the transition frontier or in transaction pool but is not on the longest chain
UNKNOWN: The transaction has either been snarked, reached finality through consensus or has been dropped
Defined in
Undefined
Ƭ Undefined: undefined
Defined in
Void
Ƭ Void: undefined
Defined in
ZkappPublicInput
Ƭ ZkappPublicInput: Object
The public input for zkApps consists of certain hashes of the proving AccountUpdate (and its child accountUpdates) which is constructed during method execution.
For SmartContract proving, a method is run twice: First outside the proof, to obtain the public input, and once in the prover, which takes the public input as input. The current transaction is hashed again inside the prover, which asserts that the result equals the input public input, as part of the snark circuit. The block producer will also hash the transaction they receive and pass it as a public input to the verifier. Thus, the transaction is fully constrained by the proof - the proof couldn't be used to attest to a different transaction.
Type declaration
Name | Type |
---|---|
accountUpdate | Field |
calls | Field |
Defined in
Variables
Cache
• Cache: Object
Type declaration
Name | Type |
---|---|
FileSystem | (cacheDirectory : string , debug? : boolean ) => Cache |
FileSystemDefault | Cache |
None | Cache |
Defined in
Empty
• Empty: ProvablePureExtended
<undefined
, null
>
Defined in
FieldConst
• FieldConst: Object
Type declaration
Name | Type |
---|---|
-1 | FieldConst |
0 | FieldConst |
1 | FieldConst |
fromBigint | (x : bigint ) => FieldConst |
toBigint | (x : FieldConst ) => Fp |
equal | (x : FieldConst , y : FieldConst ) => boolean |
Defined in
FieldVar
• FieldVar: Object
Type declaration
Name | Type |
---|---|
-1 | [Constant , FieldConst ] |
0 | [Constant , FieldConst ] |
1 | [Constant , FieldConst ] |
add | (x : FieldVar , y : FieldVar ) => FieldVar |
constant | (x : bigint | FieldConst ) => ConstantFieldVar |
isConstant | (x : FieldVar ) => x is ConstantFieldVar |
scale | (c : FieldConst , x : FieldVar ) => FieldVar |
Defined in
Gadgets
• Const
Gadgets: Object
Type declaration
Name | Type |
---|---|
and | (a : Field , b : Field , length : number ) => Field |
rangeCheck64 | (x : Field ) => void |
rotate | (field : Field , bits : number , direction : "left" | "right" ) => Field |
xor | (a : Field , b : Field , length : number ) => Field |
Defined in
Permissions
• Permissions: Object
Type declaration
Name | Type |
---|---|
allImpossible | () => Permissions |
default | () => Permissions |
dummy | () => Permissions |
fromJSON | (permissions : { access : AuthRequired ; editActionState : AuthRequired ; editState : AuthRequired ; incrementNonce : AuthRequired ; receive : AuthRequired ; send : AuthRequired ; setDelegate : AuthRequired ; setPermissions : AuthRequired ; setTiming : AuthRequired ; setTokenSymbol : AuthRequired ; setVerificationKey : AuthRequired ; setVotingFor : AuthRequired ; setZkappUri : AuthRequired }) => Permissions |
fromString | (permission : AuthRequired ) => AuthRequired |
impossible | () => AuthRequired |
initial | () => Permissions |
none | () => AuthRequired |
proof | () => AuthRequired |
proofOrSignature | () => AuthRequired |
signature | () => AuthRequired |
Defined in
Pickles
• Pickles: Object
Type declaration
Name | Type |
---|---|
compile | (rules : MlArray <Rule >, config : { overrideWrapDomain? : 0 | 2 | 1 ; publicInputSize : number ; publicOutputSize : number ; storable? : Cache }) => { getVerificationKey : () => [_: 0, data: string, hash: FieldConst] ; provers : MlArray <Prover > ; tag : unknown ; verify : (statement : Statement <FieldConst >, proof : unknown ) => Promise <boolean > } |
decodeVerificationKey | (vk : string ) => MlWrapVerificationKey |
dummyProof | <N>(maxProofsVerified : N , domainLog2 : number ) => [N , unknown ] |
dummyVerificationKey | () => [_: 0, data: string, hash: FieldConst] |
encodeVerificationKey | (vk : MlWrapVerificationKey ) => string |
proofOfBase64 | <N>(base64 : string , maxProofsVerified : N ) => [N , unknown ] |
proofToBase64 | (proof : [0 | 2 | 1 , unknown ]) => string |
proofToBase64Transaction | (proof : unknown ) => string |
util | { fromMlString : (s : MlBytes ) => string ; toMlString : (s : string ) => MlBytes } |
util.fromMlString | [object Object] |
util.toMlString | [object Object] |
loadSrsFp | () => WasmFpSrs |
loadSrsFq | () => WasmFqSrs |
verify | (statement : Statement <FieldConst >, proof : unknown , verificationKey : string ) => Promise <boolean > |
Defined in
Poseidon
• Const
Poseidon: Object
Type declaration
Name | Type |
---|---|
Sponge | typeof Sponge |
hash | (input : Field []) => Field |
hashToGroup | (input : Field []) => { x : Field ; y : { x0 : Field ; x1 : Field } } |
initialState | () => [Field , Field , Field ] |
update | (state : [Field , Field , Field ], input : Field []) => Field [] |
Defined in
Provable
• Provable: Object
Type declaration
Name | Type |
---|---|
Array | <A>(elementType : A , length : number ) => InferredProvable <A []> |
asProver | (f : () => void ) => void |
assertEqual | <T>(type : FlexibleProvable <T >, x : T , y : T ) => void <T>(x : T , y : T ) => void |
constraintSystem | <T>(f : () => T ) => { digest : string ; gates : Gate [] ; publicInputSize : number ; result : T ; rows : number } |
equal | <T>(type : FlexibleProvable <T >, x : T , y : T ) => Bool <T>(x : T , y : T ) => Bool |
if | <T>(condition : Bool , type : FlexibleProvable <T >, x : T , y : T ) => T <T>(condition : Bool , x : T , y : T ) => T |
inCheckedComputation | () => boolean |
inProver | () => boolean |
log | (...args : any ) => void |
runAndCheck | (f : () => void ) => void |
runUnchecked | (f : () => void ) => void |
switch | <T, A>(mask : Bool [], type : A , values : T []) => T |
witness | <T, S>(type : S , compute : () => T ) => T |
Defined in
Snarky
• Snarky: Object
Internal interface to snarky-ml
Note for devs: This module is intended to closely mirror snarky-ml's core, low-level APIs.
Type declaration
Name | Type | Description |
---|---|---|
bool | { and : (x : FieldVar , y : FieldVar ) => FieldVar ; assertEqual : (x : FieldVar , y : FieldVar ) => void ; equals : (x : FieldVar , y : FieldVar ) => FieldVar ; not : (x : FieldVar ) => FieldVar ; or : (x : FieldVar , y : FieldVar ) => FieldVar } | - |
bool.and | [object Object] | - |
bool.assertEqual | [object Object] | - |
bool.equals | [object Object] | - |
bool.not | [object Object] | - |
bool.or | [object Object] | - |
circuit | { keypair : { getConstraintSystemJSON : (keypair : unknown ) => JsonConstraintSystem ; getVerificationKey : (keypair : unknown ) => unknown } ; compile : (main : Main , publicInputSize : number ) => unknown ; prove : (main : Main , publicInputSize : number , publicInput : MlArray <FieldConst >, keypair : unknown ) => unknown ; verify : (publicInput : MlArray <FieldConst >, proof : unknown , verificationKey : unknown ) => boolean } | The circuit API is a low level interface to create zero-knowledge proofs |
circuit.keypair | { getConstraintSystemJSON : (keypair : unknown ) => JsonConstraintSystem ; getVerificationKey : (keypair : unknown ) => unknown } | - |
circuit.keypair.getConstraintSystemJSON | [object Object] | Returns a low-level JSON representation of the circuit: a list of gates, each of which represents a row in a table, with certain coefficients and wires to other (row, column) pairs |
circuit.keypair.getVerificationKey | [object Object] | - |
circuit.compile | [object Object] | Generates a proving key and a verification key for the provable function main |
circuit.prove | [object Object] | Proves a statement using the private input, public input and the keypair of the circuit. |
circuit.verify | [object Object] | Verifies a proof using the public input, the proof and the verification key of the circuit. |
field | { add : (x : FieldVar , y : FieldVar ) => FieldVar ; assertBoolean : (x : FieldVar ) => void ; assertEqual : (x : FieldVar , y : FieldVar ) => void ; assertMul : (x : FieldVar , y : FieldVar , z : FieldVar ) => void ; assertSquare : (x : FieldVar , y : FieldVar ) => void ; compare : (bitLength : number , x : FieldVar , y : FieldVar ) => [_: 0, less: FieldVar, lessOrEqual: FieldVar] ; fromBits : (bits : MlArray <FieldVar >) => FieldVar ; mul : (x : FieldVar , y : FieldVar ) => FieldVar ; readVar : (x : FieldVar ) => FieldConst ; scale : (c : FieldConst , x : FieldVar ) => FieldVar ; seal : (x : FieldVar ) => FieldVar ; toBits : (length : number , x : FieldVar ) => MlArray <FieldVar > ; toConstantAndTerms : (x : FieldVar ) => [_: 0, constant: MlOption<FieldConst>, terms: MlList<MlPair<FieldConst, number>>] ; truncateToBits16 : (lengthDiv16 : number , x : FieldVar ) => FieldVar } | APIs to add constraints on field variables |
field.add | [object Object] | add x, y to get a new AST node Add(x, y); handles if x, y are constants |
field.assertBoolean | [object Object] | x*x === x without handling of constants |
field.assertEqual | [object Object] | x === y without handling of constants |
field.assertMul | [object Object] | x*y === z without handling of constants |
field.assertSquare | [object Object] | x*x === y without handling of constants |
field.compare | [object Object] | check x < y and x <= y |
field.fromBits | [object Object] | |
field.mul | [object Object] | witnesses z = x*y and constrains it with [assert_r1cs]; handles constants |
field.readVar | [object Object] | evaluates a CVar by walking the AST and reading Vars from a list of public input + aux values |
field.scale | [object Object] | scale x by a constant to get a new AST node Scale(c, x); handles if x is a constant |
field.seal | [object Object] | returns a new witness from an AST (implemented with toConstantAndTerms) |
field.toBits | [object Object] | |
field.toConstantAndTerms | [object Object] | Unfolds AST to get x = c + c0*Var(i0) + ... + cn*Var(in) , returns (c, [(c0, i0), ..., (cn, in)]) ; c is optional |
field.truncateToBits16 | [object Object] | returns x truncated to the lowest 16 * lengthDiv16 bits => can be used to assert that x fits in 16 * lengthDiv16 bits. more efficient than toBits() because it uses the EC_endoscalar gate; does 16 bits per row (vs 1 bits per row that you can do with generic gates). |
gates | { addFixedLookupTable : (id : number , data : MlArray <MlArray <FieldConst >>) => void ; addRuntimeTableConfig : (id : number , firstColumn : MlArray <FieldConst >) => void ; ecAdd : (p1 : MlGroup , p2 : MlGroup , p3 : MlGroup , inf : FieldVar , same_x : FieldVar , slope : FieldVar , inf_z : FieldVar , x21_inv : FieldVar ) => MlGroup ; ecEndoscalar : (state : MlArray <[_: 0, n0: FieldVar, n8: FieldVar, a0: FieldVar, b0: FieldVar, a8: FieldVar, b8: FieldVar, x0: FieldVar, x1: FieldVar, x2: FieldVar, x3: FieldVar]>) => void ; ecEndoscale : (state : MlArray <[_: 0, xt: FieldVar, yt: FieldVar, xp: FieldVar, yp: FieldVar, nAcc: FieldVar, xr: FieldVar, yr: FieldVar, s1: FieldVar, s3: FieldVar, b1: FieldVar]>, xs : FieldVar , ys : FieldVar , nAcc : FieldVar ) => void ; ecScale : (state : MlArray <[_: 0, accs: MlArray<[0, FieldVar, FieldVar]>, bits: MlArray<FieldVar>, ss: MlArray<FieldVar>, base: MlGroup, nPrev: Field, nNext: Field]>) => void ; foreignFieldAdd : (left : [0 , FieldVar , FieldVar , FieldVar ], right : [0 , FieldVar , FieldVar , FieldVar ], fieldOverflow : FieldVar , carry : FieldVar , foreignFieldModulus : [0 , FieldConst , FieldConst , FieldConst ], sign : FieldConst ) => void ; foreignFieldMul : (left : [0 , FieldVar , FieldVar , FieldVar ], right : [0 , FieldVar , FieldVar , FieldVar ], remainder : [0 , FieldVar , FieldVar ], quotient : [0 , FieldVar , FieldVar , FieldVar ], quotientHiBound : FieldVar , product1 : [0 , FieldVar , FieldVar , FieldVar ], carry0 : FieldVar , carry1p : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ], carry1c : [0 , FieldVar , FieldVar , FieldVar , FieldVar ], foreignFieldModulus2 : FieldConst , negForeignFieldModulus : [0 , FieldConst , FieldConst , FieldConst ]) => void ; generic : (sl : FieldConst , l : FieldVar , sr : FieldConst , r : FieldVar , so : FieldConst , o : FieldVar , sm : FieldConst , sc : FieldConst ) => void ; lookup : (input : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ]) => void ; poseidon : (state : MlArray <[0 , Field , Field , Field ]>) => void ; rangeCheck0 : (v0 : FieldVar , v0p : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ], v0c : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ], compact : FieldConst ) => void ; rangeCheck1 : (v2 : FieldVar , v12 : FieldVar , vCurr : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ], vNext : [0 , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar , FieldVar ]) => void ; raw : (kind : KimchiGateType , values : MlArray <FieldVar >, coefficients : MlArray <FieldConst >) => void ; rotate : (field : FieldVar , rotated : FieldVar , excess : FieldVar , limbs : MlArray <FieldVar >, crumbs : MlArray <FieldVar >, two_to_rot : FieldConst ) => void ; xor : (in1 : FieldVar , in2 : FieldVar , out : FieldVar , in1_0 : FieldVar , in1_1 : FieldVar , in1_2 : FieldVar , in1_3 : FieldVar , in2_0 : FieldVar , in2_1 : FieldVar , in2_2 : FieldVar , in2_3 : FieldVar , out_0 : FieldVar , out_1 : FieldVar , out_2 : FieldVar , out_3 : FieldVar ) => void ; zero : (in1 : FieldVar , in2 : FieldVar , out : FieldVar ) => void } | - |
gates.addFixedLookupTable | [object Object] | - |
gates.addRuntimeTableConfig | [object Object] | - |
gates.ecAdd | [object Object] | Low-level Elliptic Curve Addition gate. |
gates.ecEndoscalar | [object Object] | - |
gates.ecEndoscale | [object Object] | - |
gates.ecScale | [object Object] | - |
gates.foreignFieldAdd | [object Object] | - |
gates.foreignFieldMul | [object Object] | - |
gates.generic | [object Object] | - |
gates.lookup | [object Object] | - |
gates.poseidon | [object Object] | - |
gates.rangeCheck0 | [object Object] | Range check gate |
gates.rangeCheck1 | [object Object] | - |
gates.raw | [object Object] | - |
gates.rotate | [object Object] | - |
gates.xor | [object Object] | - |
gates.zero | [object Object] | - |
group | { scale : (p : MlGroup , s : MlArray <FieldVar >) => MlGroup } | - |
group.scale | [object Object] | - |
poseidon | { sponge : { absorb : (sponge : unknown , x : FieldVar ) => void ; create : (isChecked : boolean ) => unknown ; squeeze : (sponge : unknown ) => FieldVar } ; hashToGroup : (input : MlArray <FieldVar >) => MlPair <FieldVar , FieldVar > ; update : (state : MlArray <FieldVar >, input : MlArray <FieldVar >) => [0 , FieldVar , FieldVar , FieldVar ] } | - |
poseidon.sponge | { absorb : (sponge : unknown , x : FieldVar ) => void ; create : (isChecked : boolean ) => unknown ; squeeze : (sponge : unknown ) => FieldVar } | - |
poseidon.sponge.absorb | [object Object] | - |
poseidon.sponge.create | [object Object] | - |
poseidon.sponge.squeeze | [object Object] | - |
poseidon.hashToGroup | [object Object] | - |
poseidon.update | [object Object] | - |
run | { asProver : (f : () => void ) => void ; constraintSystem : (f : () => void ) => { digest : string ; json : JsonConstraintSystem ; rows : number } ; inProverBlock : () => boolean ; runAndCheck : (f : () => void ) => void ; runUnchecked : (f : () => void ) => void } | APIs that have to do with running provable code |
run.asProver | [object Object] | Runs code as a prover. |
run.constraintSystem | [object Object] | Returns information about the constraint system in the callback function. |
run.inProverBlock | [object Object] | Check whether we are inside an asProver or exists block |
run.runAndCheck | [object Object] | Runs code and checks its correctness. |
run.runUnchecked | [object Object] | Runs code in prover mode, without checking correctness. |
exists | (sizeInFields : number , compute : () => MlArray <FieldConst >) => MlArray <FieldVar > | witness sizeInFields field element variables Note: this is called "exists" because in a proof, you use it like this: > "I prove that there exists x, such that (some statement)" |
existsVar | (compute : () => FieldConst ) => FieldVar | witness a single field element variable |
Defined in
Test
• Const
Test: Object
Type declaration
Name | Type |
---|---|
encoding | { memoHashBase58 : (memoBase58 : string ) => FieldConst ; memoToBase58 : (memoString : string ) => string ; ofBase58 : (base58 : string , versionByte : number ) => MlBytes ; privateKeyOfBase58 : (privateKeyBase58 : string ) => ScalarConst ; privateKeyToBase58 : (privateKey : ScalarConst ) => string ; publicKeyOfBase58 : (publicKeyBase58 : string ) => MlPublicKey ; publicKeyToBase58 : (publicKey : MlPublicKey ) => string ; toBase58 : (s : MlBytes , versionByte : number ) => string ; tokenIdOfBase58 : (fieldBase58 : string ) => FieldConst ; tokenIdToBase58 : (field : FieldConst ) => string } |
encoding.memoHashBase58 | [object Object] |
encoding.memoToBase58 | [object Object] |
encoding.ofBase58 | [object Object] |
encoding.privateKeyOfBase58 | [object Object] |
encoding.privateKeyToBase58 | [object Object] |
encoding.publicKeyOfBase58 | [object Object] |
encoding.publicKeyToBase58 | [object Object] |
encoding.toBase58 | [object Object] |
encoding.tokenIdOfBase58 | [object Object] |
encoding.tokenIdToBase58 | [object Object] |
fieldsFromJson | { accountUpdate : (json : string ) => MlArray <FieldConst > } |
fieldsFromJson.accountUpdate | [object Object] |
hashFromJson | { accountUpdate : (json : string ) => FieldConst ; transactionCommitments : (txJson : string ) => { commitment : FieldConst ; feePayerHash : FieldConst ; fullCommitment : FieldConst } ; zkappPublicInput : (txJson : string , accountUpdateIndex : number ) => { accountUpdate : FieldConst ; calls : FieldConst } } |
hashFromJson.accountUpdate | [object Object] |
hashFromJson.transactionCommitments | [object Object] |
hashFromJson.zkappPublicInput | [object Object] |
hashInputFromJson | { accountPrecondition : (json : String ) => MlHashInput ; body : (json : String ) => MlHashInput ; networkPrecondition : (json : String ) => MlHashInput ; packInput : (input : MlHashInput ) => MlArray <FieldConst > ; permissions : (json : String ) => MlHashInput ; timing : (json : String ) => MlHashInput ; update : (json : String ) => MlHashInput } |
hashInputFromJson.accountPrecondition | [object Object] |
hashInputFromJson.body | [object Object] |
hashInputFromJson.networkPrecondition | [object Object] |
hashInputFromJson.packInput | [object Object] |
hashInputFromJson.permissions | [object Object] |
hashInputFromJson.timing | [object Object] |
hashInputFromJson.update | [object Object] |
poseidon | { hashToGroup : (input : MlArray <FieldConst >) => MlPair <FieldConst , FieldConst > } |
poseidon.hashToGroup | [object Object] |
signature | { dummySignature : () => string ; signFieldElement : (messageHash : FieldConst , privateKey : ScalarConst , isMainnet : boolean ) => string } |
signature.dummySignature | [object Object] |
signature.signFieldElement | [object Object] |
tokenId | { derive : (publicKey : MlPublicKey , tokenId : FieldConst ) => FieldConst ; deriveChecked : (publicKey : MlPublicKeyVar , tokenId : FieldVar ) => FieldVar } |
tokenId.derive | [object Object] |
tokenId.deriveChecked | [object Object] |
transactionHash | { examplePayment : () => string ; hashPayment : (payment : string ) => string ; hashPaymentV1 : (payment : string ) => string ; serializeCommon : (common : string ) => { data : Uint8Array } ; serializePayment : (payment : string ) => { data : Uint8Array } ; serializePaymentV1 : (payment : string ) => string } |
transactionHash.examplePayment | [object Object] |
transactionHash.hashPayment | [object Object] |
transactionHash.hashPaymentV1 | [object Object] |
transactionHash.serializeCommon | [object Object] |
transactionHash.serializePayment | [object Object] |
transactionHash.serializePaymentV1 | [object Object] |
Defined in
TokenId
• Const
TokenId: Object
Type declaration
Name | Type |
---|---|
check | (x : Field ) => void |
default | Field |
fromFields | (x : Field [], aux : any []) => Field |
toAuxiliary | (x? : Field ) => any [] |
toFields | (x : Field ) => Field [] |
toInput | (x : Field ) => { fields? : Field [] ; packed? : [Field , number ][] } |
derive | (tokenOwner : PublicKey , parentTokenId : Field ) => Field |
emptyValue | () => Field |
fromBase58 | (base58 : string ) => Field |
fromJSON | (x : string ) => Field |
sizeInFields | () => number |
toBase58 | (t : Field ) => string |
toJSON | (x : Field ) => string |
Defined in
Undefined
• Undefined: ProvablePureExtended
<undefined
, null
>
Defined in
Void
• Void: ProvablePureExtended
<void
, null
>
Defined in
ZkappPublicInput
• ZkappPublicInput: ProvablePure
<{ accountUpdate
: Field
= Field; calls
: Field
= Field }> & ProvableExtension
<{ accountUpdate
: Field
= Field; calls
: Field
= Field }, { accountUpdate
: string
= Field; calls
: string
= Field }>
Defined in
isReady
• isReady: Promise
<void
>
Deprecated
await isReady
is no longer needed. Remove it from your code.
Defined in
Functions
Account
▸ Account(address
, tokenId?
): Account
Parameters
Name | Type |
---|---|
address | PublicKey |
tokenId? | Field |
Returns
Account
Defined in
Bool
▸ Bool(...args
): Bool
A boolean value. You can create it like this:
Example
const b = Bool(true);
You can also combine multiple Bools with boolean operations:
Example
const c = Bool(false);
const d = b.or(c).and(false).not();
d.assertTrue();
Bools are often created by methods on other types such as Field.equals()
:
const b: Bool = Field(5).equals(6);
Parameters
Name | Type |
---|---|
...args | [x: boolean | Bool | FieldVar] |
Returns
Defined in
Field
▸ Field(...args
): Field
A Field is an element of a prime order finite field. Every other provable type is built using the Field type.
The field is the pasta base field of order 2^254 + 0x224698fc094cf91b992d30ed00000001 (ORDER).
You can create a new Field from everything "field-like" (bigint
, integer number
, decimal string
, Field
).
Example
Field(10n); // Field construction from a bigint
Field(100); // Field construction from a number
Field("1"); // Field construction from a decimal string
Beware: Fields cannot be constructed from fractional numbers or alphanumeric strings:
Field(3.141); // ERROR: Cannot convert a float to a field element
Field("abc"); // ERROR: Invalid argument "abc"
Creating a Field from a negative number can result in unexpected behavior if you are not familiar with modular arithmetic.
Example
const x = Field(-1); // valid Field construction from negative number
const y = Field(Field.ORDER - 1n); // same as `x`
Important: All the functions defined on a Field (arithmetic, logic, etc.) take their arguments as "field-like". A Field itself is also defined as a "field-like" element.
Parameters
Name | Type |
---|---|
...args | [x: string | number | bigint | FieldVar | FieldConst | Field] |
Returns
A Field with the value converted from the argument
Defined in
Group
▸ Group(...args
): Group
An element of a Group.
Parameters
Name | Type |
---|---|
...args | [{ x : string | number | bigint | FieldVar | Field ; y : string | number | bigint | FieldVar | Field }] |
Returns
Defined in
MerkleWitness
▸ MerkleWitness(height
): typeof BaseMerkleWitness
Returns a circuit-compatible Witness for a specific Tree height.
Parameters
Name | Type | Description |
---|---|---|
height | number | Height of the Merkle Tree that this Witness belongs to. |
Returns
typeof BaseMerkleWitness
A circuit-compatible Merkle Witness.
Defined in
Reducer
▸ Reducer<T
, A
>(reducer
): ReducerReturn
<A
>
Type parameters
Name | Type |
---|---|
T | extends FlexibleProvablePure <any > |
A | extends any = InferProvable <T > |
Parameters
Name | Type |
---|---|
reducer | Object |
reducer.actionType | T |
Returns
ReducerReturn
<A
>
Defined in
State
▸ State<A
>(): State
<A
>
Type parameters
Name |
---|
A |
Returns
State
<A
>
Defined in
Struct
▸ Struct<A
, T
, J
, Pure
>(type
): (value
: T
) => T
& { _isStruct
: true
} & Pure
extends true
? ProvablePure
<T
> : Provable
<T
> & { fromJSON
: (x
: J
) => T
; toInput
: (x
: T
) => { fields?
: Field
[] ; packed?
: [Field
, number
][] } ; toJSON
: (x
: T
) => J
}
Struct
lets you declare composite types for use in o1js circuits.
These composite types can be passed in as arguments to smart contract methods, used for on-chain state variables or as event / action types.
Here's an example of creating a "Voter" struct, which holds a public key and a collection of votes on 3 different proposals:
let Vote = { hasVoted: Bool, inFavor: Bool };
class Voter extends Struct({
publicKey: PublicKey,
votes: [Vote, Vote, Vote]
}) {}
// use Voter as SmartContract input:
class VoterContract extends SmartContract {
\@method register(voter: Voter) {
// ...
}
}
In this example, there are no instance methods on the class. This makes Voter
type-compatible with an anonymous object of the form
{ publicKey: PublicKey, votes: Vote[] }
.
This mean you don't have to create instances by using new Voter(...)
, you can operate with plain objects:
voterContract.register({ publicKey, votes });
On the other hand, you can also add your own methods:
class Voter extends Struct({
publicKey: PublicKey,
votes: [Vote, Vote, Vote]
}) {
vote(index: number, inFavor: Bool) {
let vote = this.votes[i];
vote.hasVoted = Bool(true);
vote.inFavor = inFavor;
}
}
In this case, you'll need the constructor to create instances of Voter
. It always takes as input the plain object:
let emptyVote = { hasVoted: Bool(false), inFavor: Bool(false) };
let voter = new Voter({ publicKey, votes: Array(3).fill(emptyVote) });
voter.vote(1, Bool(true));
In addition to creating types composed of Field elements, you can also include auxiliary data which does not become part of the proof. This, for example, allows you to re-use the same type outside o1js methods, where you might want to store additional metadata.
To declare non-proof values of type string
, number
, etc, you can use the built-in objects String
, Number
, etc.
Here's how we could add the voter's name (a string) as auxiliary data:
class Voter extends Struct({
publicKey: PublicKey,
votes: [Vote, Vote, Vote],
fullName: String
}) {}
Again, it's important to note that this doesn't enable you to prove anything about the fullName
string.
From the circuit point of view, it simply doesn't exist!
Type parameters
Name | Type |
---|---|
A | A |
T | extends unknown = InferProvable <A > |
J | extends unknown = InferJson <A > |
Pure | extends boolean = IsPure <A > |
Parameters
Name | Type | Description |
---|---|---|
type | A | Object specifying the layout of the Struct |
Returns
(value
: T
) => T
& { _isStruct
: true
} & Pure
extends true
? ProvablePure
<T
> : Provable
<T
> & { fromJSON
: (x
: J
) => T
; toInput
: (x
: T
) => { fields?
: Field
[] ; packed?
: [Field
, number
][] } ; toJSON
: (x
: T
) => J
}
Class which you can extend
Defined in
ZkProgram
▸ ZkProgram<StatementType
, Types
>(config
): { analyzeMethods
: () => ReturnType
<typeof analyzeMethod
>[] ; compile
: () => Promise
<{ verificationKey
: string
}> ; digest
: () => string
; name
: string
; publicInputType
: ProvableOrUndefined
<Get
<StatementType
, "publicInput"
>> ; publicOutputType
: ProvableOrVoid
<Get
<StatementType
, "publicOutput"
>> ; verify
: (proof
: Proof
<InferProvableOrUndefined
<Get
<StatementType
, "publicInput"
>>, InferProvableOrVoid
<Get
<StatementType
, "publicOutput"
>>>) => Promise
<boolean
> } & { [I in keyof Types]: Prover<InferProvableOrUndefined<Get<StatementType, "publicInput">>, InferProvableOrVoid<Get<StatementType, "publicOutput">>, Types[I]> }
Type parameters
Name | Type |
---|---|
StatementType | extends Object |
Types | extends Object |
Parameters
Name | Type |
---|---|
config | StatementType & { methods : { [I in string | number | symbol]: Method<InferProvableOrUndefined<Get<StatementType, "publicInput">>, InferProvableOrVoid<Get<StatementType, "publicOutput">>, Types[I]> } ; name : string ; overrideWrapDomain? : 0 | 2 | 1 } |
Returns
{ analyzeMethods
: () => ReturnType
<typeof analyzeMethod
>[] ; compile
: () => Promise
<{ verificationKey
: string
}> ; digest
: () => string
; name
: string
; publicInputType
: ProvableOrUndefined
<Get
<StatementType
, "publicInput"
>> ; publicOutputType
: ProvableOrVoid
<Get
<StatementType
, "publicOutput"
>> ; verify
: (proof
: Proof
<InferProvableOrUndefined
<Get
<StatementType
, "publicInput"
>>, InferProvableOrVoid
<Get
<StatementType
, "publicOutput"
>>>) => Promise
<boolean
> } & { [I in keyof Types]: Prover<InferProvableOrUndefined<Get<StatementType, "publicInput">>, InferProvableOrVoid<Get<StatementType, "publicOutput">>, Types[I]> }
Defined in
addCachedAccount
▸ addCachedAccount(partialAccount
, graphqlEndpoint?
): void
Adds an account to the local cache, indexed by a GraphQL endpoint.
Parameters
Name | Type | Default value |
---|---|---|
partialAccount | PartialAccount | undefined |
graphqlEndpoint | string | networkConfig.minaEndpoint |
Returns
void
Defined in
arrayProp
▸ arrayProp<T
>(elementType
, length
): (target
: any
, key
: string
) => void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
elementType | FlexibleProvable <T > |
length | number |
Returns
fn
▸ (target
, key
): void
Parameters
Name | Type |
---|---|
target | any |
key | string |
Returns
void
Defined in
checkZkappTransaction
▸ checkZkappTransaction(txnId
): Promise
<{ failureReason
: string
[] ; success
: boolean
= false } | { failureReason
: null
= null; success
: boolean
= true }>
Parameters
Name | Type |
---|---|
txnId | string |
Returns
Promise
<{ failureReason
: string
[] ; success
: boolean
= false } | { failureReason
: null
= null; success
: boolean
= true }>
Defined in
circuitMain
▸ circuitMain(target
, propertyName
, _descriptor?
): any
Parameters
Name | Type |
---|---|
target | typeof Circuit |
propertyName | string |
_descriptor? | PropertyDescriptor |
Returns
any
Defined in
declareMethods
▸ declareMethods<T
>(SmartContract
, methodArguments
): void
declareMethods
can be used in place of the @method
decorator
to declare SmartContract methods along with their list of arguments.
It should be placed after the class declaration.
Here is an example of declaring a method update
, which takes a single argument of type Field
:
class MyContract extends SmartContract {
// ...
update(x: Field) {
// ...
}
}
declareMethods(MyContract, { update: [Field] }); // `[Field]` is the list of arguments!
Note that a method of the same name must still be defined on the class, just without the decorator.
Type parameters
Name | Type |
---|---|
T | extends typeof SmartContract |
Parameters
Name | Type |
---|---|
SmartContract | T |
methodArguments | Record <string , Provable <unknown >[]> |
Returns
void
Defined in
declareState
▸ declareState<T
>(SmartContract
, states
): void
declareState
can be used in place of the @state
decorator to declare on-chain state on a SmartContract.
It should be placed after the class declaration.
Here is an example of declaring a state property x
of type Field
.
class MyContract extends SmartContract {
x = State<Field>();
// ...
}
declareState(MyContract, { x: Field });
If you're using pure JS, it's not possible to use the built-in class field syntax, i.e. the following will not work:
// THIS IS WRONG IN JS!
class MyContract extends SmartContract {
x = State();
}
declareState(MyContract, { x: Field });
Instead, add a constructor where you assign the property:
class MyContract extends SmartContract {
constructor(x) {
super();
this.x = State();
}
}
declareState(MyContract, { x: Field });
Type parameters
Name | Type |
---|---|
T | extends typeof SmartContract |
Parameters
Name | Type |
---|---|
SmartContract | T |
states | Record <string , FlexibleProvablePure <unknown >> |
Returns
void
Defined in
fetchAccount
▸ fetchAccount(accountInfo
, graphqlEndpoint?
, «destructured»?
): Promise
<{ account
: Account
; error
: undefined
} | { account
: undefined
; error
: FetchError
}>
Gets account information on the specified publicKey by performing a GraphQL query to the specified endpoint. This will call the 'GetAccountInfo' query which fetches zkapp related account information.
If an error is returned by the specified endpoint, an error is thrown. Otherwise, the data is returned.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
accountInfo | Object | undefined | - |
accountInfo.publicKey | string | PublicKey | undefined | - |
accountInfo.tokenId? | string | Field | undefined | - |
graphqlEndpoint | string | networkConfig.minaEndpoint | The graphql endpoint to fetch from |
«destructured» | Object | {} | - |
› timeout | undefined | number | undefined | - |
Returns
Promise
<{ account
: Account
; error
: undefined
} | { account
: undefined
; error
: FetchError
}>
zkapp information on the specified account or an error is thrown
Defined in
fetchEvents
▸ fetchEvents(accountInfo
, graphqlEndpoint?
, filterOptions?
): Promise
<{ blockHash
: string
= event.blockInfo.stateHash; blockHeight
: UInt32
; chainStatus
: string
= event.blockInfo.chainStatus; events
: { data
: string
[] ; transactionInfo
: { hash
: string
; memo
: string
; status
: string
} }[] ; globalSlot
: UInt32
; parentBlockHash
: string
= event.blockInfo.parentHash }[]>
Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API.
Async
Throws
If the GraphQL request fails or the response is invalid.
Example
const accountInfo = { publicKey: 'B62qiwmXrWn7Cok5VhhB3KvCwyZ7NHHstFGbiU5n7m8s2RqqNW1p1wF' };
const events = await fetchEvents(accountInfo);
console.log(events);
Parameters
Name | Type | Default value | Description |
---|---|---|---|
accountInfo | Object | undefined | The account information object. |
accountInfo.publicKey | string | undefined | The account public key. |
accountInfo.tokenId? | string | undefined | The optional token ID for the account. |
graphqlEndpoint? | string | networkConfig.archiveEndpoint | The GraphQL endpoint to query. Defaults to the Archive Node GraphQL API. |
filterOptions? | EventActionFilterOptions | {} | The optional filter options object. |
Returns
Promise
<{ blockHash
: string
= event.blockInfo.stateHash; blockHeight
: UInt32
; chainStatus
: string
= event.blockInfo.chainStatus; events
: { data
: string
[] ; transactionInfo
: { hash
: string
; memo
: string
; status
: string
} }[] ; globalSlot
: UInt32
; parentBlockHash
: string
= event.blockInfo.parentHash }[]>
A promise that resolves to an array of objects containing event data, block information and transaction information for the account.
Defined in
fetchLastBlock
▸ fetchLastBlock(graphqlEndpoint?
): Promise
<PreconditionBaseTypes
<{ blockchainLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; globalSlotSinceGenesis
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; minWindowDensity
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; nextEpochData
: { epochLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; ledger
: { hash
: { isSome
: Bool
; value
: Field
} ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } } ; lockCheckpoint
: { isSome
: Bool
; value
: Field
} ; seed
: { isSome
: Bool
; value
: Field
} ; startCheckpoint
: { isSome
: Bool
; value
: Field
} } ; snarkedLedgerHash
: { isSome
: Bool
; value
: Field
} ; stakingEpochData
: { epochLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; ledger
: { hash
: { isSome
: Bool
; value
: Field
} ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } } ; lockCheckpoint
: { isSome
: Bool
; value
: Field
} ; seed
: { isSome
: Bool
; value
: Field
} ; startCheckpoint
: { isSome
: Bool
; value
: Field
} } ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } }>>
Fetches the last block on the Mina network.
Parameters
Name | Type | Default value |
---|---|---|
graphqlEndpoint | string | networkConfig.minaEndpoint |
Returns
Promise
<PreconditionBaseTypes
<{ blockchainLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; globalSlotSinceGenesis
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; minWindowDensity
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; nextEpochData
: { epochLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; ledger
: { hash
: { isSome
: Bool
; value
: Field
} ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } } ; lockCheckpoint
: { isSome
: Bool
; value
: Field
} ; seed
: { isSome
: Bool
; value
: Field
} ; startCheckpoint
: { isSome
: Bool
; value
: Field
} } ; snarkedLedgerHash
: { isSome
: Bool
; value
: Field
} ; stakingEpochData
: { epochLength
: { isSome
: Bool
; value
: { lower
: UInt32
; upper
: UInt32
} } ; ledger
: { hash
: { isSome
: Bool
; value
: Field
} ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } } ; lockCheckpoint
: { isSome
: Bool
; value
: Field
} ; seed
: { isSome
: Bool
; value
: Field
} ; startCheckpoint
: { isSome
: Bool
; value
: Field
} } ; totalCurrency
: { isSome
: Bool
; value
: { lower
: UInt64
; upper
: UInt64
} } }>>
Defined in
fetchTransactionStatus
▸ fetchTransactionStatus(txId
, graphqlEndpoint?
): Promise
<TransactionStatus
>
Fetches the status of a transaction.
Parameters
Name | Type | Default value |
---|---|---|
txId | string | undefined |
graphqlEndpoint | string | networkConfig.minaEndpoint |
Returns
Promise
<TransactionStatus
>
Defined in
getWasm
▸ getWasm(): WasmModule
Returns
WasmModule
Defined in
bindings/js/wrapper.d.ts:7
isBool
▸ isBool(x
): boolean
Parameters
Name | Type |
---|---|
x | unknown |
Returns
boolean
Defined in
isField
▸ isField(x
): x is Field
Parameters
Name | Type |
---|---|
x | unknown |
Returns
x is Field
Defined in
matrixProp
▸ matrixProp<T
>(elementType
, nRows
, nColumns
): (target
: any
, key
: string
) => void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
elementType | FlexibleProvable <T > |
nRows | number |
nColumns | number |
Returns
fn
▸ (target
, key
): void
Parameters
Name | Type |
---|---|
target | any |
key | string |
Returns
void
Defined in
method
▸ method<T
>(target
, methodName
, descriptor
): void
A decorator to use in a zkApp to mark a method as callable by anyone. You can use inside your zkApp class as:
\@method myMethod(someArg: Field) {
// your code here
}
Type parameters
Name | Type |
---|---|
T | extends SmartContract |
Parameters
Name | Type |
---|---|
target | T & { constructor : any } |
methodName | keyof T & string |
descriptor | PropertyDescriptor |
Returns
void
Defined in
prop
▸ prop(this
, target
, key
): void
Parameters
Name | Type |
---|---|
this | any |
target | any |
key | string |
Returns
void
Defined in
provable
▸ provable<A
>(typeObj
, options?
): ProvableExtended
<InferProvable
<A
>, InferJson
<A
>>
Type parameters
Name |
---|
A |
Parameters
Name | Type |
---|---|
typeObj | A |
options? | Object |
options.isPure? | boolean |
Returns
ProvableExtended
<InferProvable
<A
>, InferJson
<A
>>
Defined in
bindings/lib/provable-snarky.ts:47
provablePure
▸ provablePure<A
>(typeObj
): ProvablePure
<InferProvable
<A
>> & ProvableExtension
<InferProvable
<A
>, InferJson
<A
>>
Type parameters
Name |
---|
A |
Parameters
Name | Type |
---|---|
typeObj | A |
Returns
ProvablePure
<InferProvable
<A
>> & ProvableExtension
<InferProvable
<A
>, InferJson
<A
>>
Defined in
bindings/lib/provable-snarky.ts:222
public_
▸ public_(target
, _key
, index
): void
Parameters
Name | Type |
---|---|
target | any |
_key | string | symbol |
index | number |
Returns
void
Defined in
readVarMessage
▸ readVarMessage(methodName
, varName
, varDescription
): string
Parameters
Name | Type |
---|---|
methodName | string |
varName | string |
varDescription | string |
Returns
string
Defined in
scaleShifted
▸ scaleShifted(point
, shiftedScalar
): Group
Parameters
Name | Type |
---|---|
point | Group |
shiftedScalar | Scalar |
Returns
Defined in
sendZkapp
▸ sendZkapp(json
, graphqlEndpoint?
, «destructured»?
): Promise
<[FetchResponse
, undefined
] | [undefined
, FetchError
]>
Sends a zkApp command (transaction) to the specified GraphQL endpoint.
Parameters
Name | Type | Default value |
---|---|---|
json | string | undefined |
graphqlEndpoint | string | networkConfig.minaEndpoint |
«destructured» | Object | {} |
› timeout | undefined | number | undefined |
Returns
Promise
<[FetchResponse
, undefined
] | [undefined
, FetchError
]>
Defined in
setArchiveGraphqlEndpoint
▸ setArchiveGraphqlEndpoint(graphqlEndpoint
): void
Sets up a GraphQL endpoint to be used for fetching information from an Archive Node.
Parameters
Name | Type |
---|---|
graphqlEndpoint | string |
Returns
void
Defined in
setGraphqlEndpoint
▸ setGraphqlEndpoint(graphqlEndpoint
): void
Parameters
Name | Type |
---|---|
graphqlEndpoint | string |
Returns
void
Defined in
setGraphqlEndpoints
▸ setGraphqlEndpoints(«destructured»
): void
Parameters
Name | Type |
---|---|
«destructured» | string [] |
Returns
void
Defined in
shutdown
▸ shutdown(): void
Deprecated
shutdown()
is no longer needed, and is a no-op. Remove it from your code.
Returns
void
Defined in
state
▸ state<A
>(stateType
): (target
: SmartContract
& { constructor
: any
}, key
: string
, _descriptor?
: PropertyDescriptor
) => void
A decorator to use within a zkapp to indicate what will be stored on-chain.
For example, if you want to store a field element some_state
in a zkapp,
you can use the following in the declaration of your zkapp:
@state(Field) some_state = State<Field>();
Type parameters
Name |
---|
A |
Parameters
Name | Type |
---|---|
stateType | FlexibleProvablePure <A > |
Returns
fn
▸ (target
, key
, _descriptor?
): void
Parameters
Name | Type |
---|---|
target | SmartContract & { constructor : any } |
key | string |
_descriptor? | PropertyDescriptor |
Returns
void
Defined in
toConstantField
▸ toConstantField(x
, methodName
, varName?
, varDescription?
): ConstantField
Parameters
Name | Type | Default value |
---|---|---|
x | Field | undefined |
methodName | string | undefined |
varName | string | 'x' |
varDescription | string | 'field element' |
Returns
Defined in
toFp
▸ toFp(x
): Fp
Parameters
Name | Type |
---|---|
x | string | number | bigint | Field |
Returns
Fp
Defined in
verify
▸ verify(proof
, verificationKey
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
proof | JsonProof | Proof <any , any > |
verificationKey | string |
Returns
Promise
<boolean
>
Defined in
withMessage
▸ withMessage(error
, message?
): unknown
Parameters
Name | Type |
---|---|
error | unknown |
message? | string |
Returns
unknown