@proto-kit/library • Docs
Documentation / @proto-kit/library / TokenId
Class: TokenId
Extends
Field
Constructors
new TokenId()
new TokenId(
x):TokenId
Coerce anything “field-like” (bigint, number, string, and Field) to a Field.
Parameters
• x: string | number | bigint | Field | FieldVar | FieldConst
Returns
Inherited from
Field.constructor
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:55
Properties
value
value:
FieldVar
Inherited from
Field.value
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:46
ORDER
staticORDER:bigint
The order of the pasta curve that Field type build on as a bigint.
Order of the Field is 28948022309329048855892746252171976963363056481941560715954676764349967630337.
Inherited from
Field.ORDER
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:51
sizeInBits
staticsizeInBits:number
The size of a Field element in bits - 255.
Inherited from
Field.sizeInBits
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:711
sizeInBytes
staticsizeInBytes:number
The size of a Field element in bytes - 32.
Inherited from
Field.sizeInBytes
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:707
Methods
add()
add(
y):Field
Add a field-like value to this Field element.
Parameters
• y: string | number | bigint | Field
a “field-like” value to add to the Field.
Returns
Field
A Field element equivalent to the modular addition of the two value.
Examples
const x = Field(3);
const sum = x.add(5);
sum.assertEquals(Field(8));Warning: This is a modular addition in the pasta field.
const x = Field(1);
const sum = x.add(Field(-7));
// If you try to print sum - `console.log(sum.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 + (-7) circles around the field to become p - 6.
// You can use the reverse operation of addition (subtraction) to prove the sum is calculated correctly.
sum.sub(x).assertEquals(Field(-7));
sum.sub(Field(-7)).assertEquals(x);Inherited from
Field.add
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:159
assertBool()
assertBool(
message?):Bool
Prove that this Field is equal to 0 or 1. Returns the Field wrapped in a Bool.
If the assertion fails, the code throws an error.
Parameters
• message?: string
a string error message to print if the assertion fails, optional.
Returns
Bool
Inherited from
Field.assertBool
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:496
assertEquals()
assertEquals(
y,message?):void
Assert that this Field is equal another “field-like” value.
Calling this function is equivalent to Field(...).equals(...).assertEquals(Bool(true)).
See Field.equals for more details.
Important: If an assertion fails, the code throws an error.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Inherited from
Field.assertEquals
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:130
assertGreaterThan()
assertGreaterThan(
y,message?):void
Assert that this Field is greater than another “field-like” value.
Note: This uses fewer constraints than x.greaterThan(y).assertTrue().
See Field.greaterThan for more details.
Important: If an assertion fails, the code throws an error.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Inherited from
Field.assertGreaterThan
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:461
assertGreaterThanOrEqual()
assertGreaterThanOrEqual(
y,message?):void
Assert that this Field is greater than or equal to another “field-like” value.
Note: This uses fewer constraints than x.greaterThanOrEqual(y).assertTrue().
See Field.greaterThanOrEqual for more details.
Important: If an assertion fails, the code throws an error.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Inherited from
Field.assertGreaterThanOrEqual
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:473
assertLessThan()
assertLessThan(
y,message?):void
Assert that this Field is less than another “field-like” value.
Note: This uses fewer constraints than x.lessThan(y).assertTrue().
See lessThan for more details.
Important: If an assertion fails, the code throws an error.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Inherited from
Field.assertLessThan
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:437
assertLessThanOrEqual()
assertLessThanOrEqual(
y,message?):void
Assert that this Field is less than or equal to another “field-like” value.
Note: This uses fewer constraints than x.lessThanOrEqual(y).assertTrue().
See Field.lessThanOrEqual for more details.
Important: If an assertion fails, the code throws an error.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Inherited from
Field.assertLessThanOrEqual
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:449
assertNotEquals()
assertNotEquals(
y,message?):void
Assert that this Field does not equal another field-like value.
Note: This uses fewer constraints than x.equals(y).assertFalse().
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare & assert with this Field.
• message?: string
a string error message to print if the assertion fails, optional.
Returns
void
Example
x.assertNotEquals(0, "expect x to be non-zero");Inherited from
Field.assertNotEquals
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:487
div()
div(
y):Field
Divide another “field-like” value through this Field.
Proves that the denominator is non-zero, or throws a “Division by zero” error.
Parameters
• y: string | number | bigint | Field
a “field-like” value to divide with the Field.
Returns
Field
A Field element equivalent to the modular division of the two value.
Examples
const x = Field(6);
const quotient = x.div(Field(3));
quotient.assertEquals(Field(2));Warning: This is a modular division in the pasta field. You can think this as the reverse operation of modular multiplication.
const x = Field(2);
const y = Field(5);
const quotient = x.div(y);
// If you try to print quotient - `console.log(quotient.toBigInt())` - you will realize that it prints a very big integer because this is a modular inverse.
// You can use the reverse operation of division (multiplication) to prove the quotient is calculated correctly.
quotient.mul(y).assertEquals(x);Inherited from
Field.div
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:293
equals()
equals(
y):Bool
Check if this Field is equal another “field-like” value. Returns a Bool, which is a provable type and can be used to prove the validity of this statement.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare with this Field.
Returns
Bool
A Bool representing if this Field is equal another “field-like” value.
Example
Field(5).equals(5).assertEquals(Bool(true));Inherited from
Field.equals
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:341
greaterThan()
greaterThan(
y):Bool
Check if this Field is greater than another “field-like” value. Returns a Bool, which is a provable type and can be used to prove the validity of this statement.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare with this Field.
Returns
Bool
A Bool representing if this Field is greater than another “field-like” value.
Examples
let isTrue = Field(5).greaterThan(3);Warning: As this method compares the bigint value of a Field, it can result in unexpected behaviour when used with negative inputs or modular division.
let isFalse = Field(1).div(2).greaterThan(Field(1).div(3); // in fact, 1/3 > 1/2Inherited from
Field.greaterThan
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:404
greaterThanOrEqual()
greaterThanOrEqual(
y):Bool
Check if this Field is greater than or equal another “field-like” value. Returns a Bool, which is a provable type and can be used to prove the validity of this statement.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare with this Field.
Returns
Bool
A Bool representing if this Field is greater than or equal another “field-like” value.
Examples
let isTrue = Field(3).greaterThanOrEqual(3);Warning: As this method compares the bigint value of a Field, it can result in unexpected behaviour when used with negative inputs or modular division.
let isFalse = Field(1).div(2).greaterThanOrEqual(Field(1).div(3); // in fact, 1/3 > 1/2Inherited from
Field.greaterThanOrEqual
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:425
inv()
inv():
Field
Modular inverse of this Field element. Equivalent to 1 divided by this Field, in the sense of modular arithmetic.
Proves that this Field is non-zero, or throws a “Division by zero” error.
Returns
Field
A Field element that is equivalent to one divided by this element.
Example
const someField = Field(42);
const inverse = someField.inv();
inverse.assertEquals(Field(1).div(someField)); // This statement is always true regardless of the value of `someField`Warning: This is a modular inverse. See div method for more details.
Inherited from
Field.inv
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:260
isConstant()
isConstant():
this is Object
Check whether this Field element is a hard-coded constant in the constraint system. If a Field is constructed outside a zkApp method, it is a constant.
Returns
this is Object
A boolean showing if this Field is a constant or not.
Examples
console.log(Field(42).isConstant()); // true\@method myMethod(x: Field) {
console.log(x.isConstant()); // false
}Inherited from
Field.isConstant
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:75
isEven()
isEven():
Bool
Checks if this Field is even. Returns true for even elements and false for odd elements.
Returns
Bool
Example
let a = Field(5);
a.isEven(); // false
let b = Field(4);
b.isEven(); // trueInherited from
Field.isEven
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:226
isOdd()
isOdd():
Bool
Checks if this Field is odd. Returns true for odd elements and false for even elements.
See Field.isEven for examples.
Returns
Bool
Inherited from
Field.isOdd
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:213
lessThan()
lessThan(
y):Bool
Check if this Field is less than another “field-like” value. Returns a Bool, which is a provable type and can be used prove to the validity of this statement.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare with this Field.
Returns
Bool
A Bool representing if this Field is less than another “field-like” value.
Examples
let isTrue = Field(2).lessThan(3);Warning: As this method compares the bigint value of a Field, it can result in unexpected behavior when used with negative inputs or modular division.
let isFalse = Field(1).div(3).lessThan(Field(1).div(2)); // in fact, 1/3 > 1/2Inherited from
Field.lessThan
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:362
lessThanOrEqual()
lessThanOrEqual(
y):Bool
Check if this Field is less than or equal to another “field-like” value. Returns a Bool, which is a provable type and can be used to prove the validity of this statement.
Parameters
• y: string | number | bigint | Field
the “field-like” value to compare with this Field.
Returns
Bool
A Bool representing if this Field is less than or equal another “field-like” value.
Examples
let isTrue = Field(3).lessThanOrEqual(3);Warning: As this method compares the bigint value of a Field, it can result in unexpected behaviour when used with negative inputs or modular division.
let isFalse = Field(1).div(3).lessThanOrEqual(Field(1).div(2)); // in fact, 1/3 > 1/2Inherited from
Field.lessThanOrEqual
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:383
mul()
mul(
y):Field
Multiply another “field-like” value with this Field element.
Parameters
• y: string | number | bigint | Field
a “field-like” value to multiply with the Field.
Returns
Field
A Field element equivalent to the modular difference of the two value.
Example
const x = Field(3);
const product = x.mul(Field(5));
product.assertEquals(Field(15));Inherited from
Field.mul
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:242
neg()
neg():
Field
Negate a Field. This is equivalent to multiplying the Field by -1.
Returns
Field
A Field element that is equivalent to the element multiplied by -1.
Examples
const negOne = Field(1).neg();
negOne.assertEquals(-1);const someField = Field(42);
someField.neg().assertEquals(someField.mul(Field(-1))); // This statement is always true regardless of the value of `someField`Warning: This is a modular negation. For details, see the sub method.
Inherited from
Field.neg
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:179
seal()
seal():
VarField|ConstantField
Warning: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer.
In o1js, addition and scaling (multiplication of variables by a constant) of variables is represented as an AST - abstract syntax tree. For example, the expression x.add(y).mul(2) is represented as Scale(2, Add(x, y)).
A new internal variable is created only when the variable is needed in a multiplicative or any higher level constraint (for example multiplication of two Field elements) to represent the operation.
The seal() function tells o1js to stop building an AST and create a new variable right away.
Returns
VarField | ConstantField
A Field element that is equal to the result of AST that was previously on this Field element.
Inherited from
Field.seal
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:534
sqrt()
sqrt():
Field
Take the square root of this Field element.
Proves that the Field element has a square root in the finite field, or throws if it doesn’t.
Returns
Field
A Field element equivalent to the square root of the Field element.
Example
let z = x.sqrt();
z.mul(z).assertEquals(x); // true for every `x`Warning: This is a modular square root, which is any number z that satisfies z*z = x (mod p). Note that, if a square root z exists, there also exists a second one, -z (which is different if z != 0). Therefore, this method leaves an adversarial prover the choice between two different values to return.
Inherited from
Field.sqrt
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:327
square()
square():
Field
Square this Field element.
Returns
Field
A Field element equivalent to the multiplication of the Field element with itself.
Example
const someField = Field(7);
const square = someField.square();
square.assertEquals(someField.mul(someField)); // This statement is always true regardless of the value of `someField`** Warning: This is a modular multiplication. See mul() method for more details.
Inherited from
Field.square
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:309
sub()
sub(
y):Field
Subtract another “field-like” value from this Field element.
Parameters
• y: string | number | bigint | Field
a “field-like” value to subtract from the Field.
Returns
Field
A Field element equivalent to the modular difference of the two value.
Examples
const x = Field(3);
const difference = x.sub(5);
difference.assertEquals(Field(-2));Warning: This is a modular subtraction in the pasta field.
const x = Field(1);
const difference = x.sub(Field(2));
// If you try to print difference - `console.log(difference.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 - 2 circles around the field to become p - 1.
// You can use the reverse operation of subtraction (addition) to prove the difference is calculated correctly.
difference.add(Field(2)).assertEquals(x);Inherited from
Field.sub
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:207
toAuxiliary()
toAuxiliary(): []
This function is the implementation of Provable.toAuxiliary for the Field type.
As the primitive Field type has no auxiliary data associated with it, this function will always return an empty array.
Returns
[]
Inherited from
Field.toAuxiliary
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:620
toBigInt()
toBigInt():
bigint
Serialize the Field to a bigint, e.g. for printing. Trying to print a Field without this function will directly stringify the Field object, resulting in unreadable output.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the bigint representation of the Field. Use the operation only during debugging.
Returns
bigint
A bigint equivalent to the bigint representation of the Field.
Example
const someField = Field(42);
console.log(someField.toBigInt());Inherited from
Field.toBigInt
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:105
toBits()
toBits(
length?):Bool[]
Returns an array of Bool elements representing little endian binary representation of this Field element.
If you use the optional length argument, proves that the field element fits in length bits.
The length has to be between 0 and 254 and the method throws if it isn’t.
Warning: The cost of this operation in a zk proof depends on the length you specify,
which by default is 254 bits. Prefer to pass a smaller length if possible.
Parameters
• length?: number
the number of bits to fit the element. If the element does not fit in length bits, the functions throws an error.
Returns
Bool[]
An array of Bool element representing little endian binary representation of this Field.
Inherited from
Field.toBits
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:510
toConstant()
toConstant():
ConstantField
Create a Field element equivalent to this Field element’s value, but is a constant. See Field.isConstant for more information about what is a constant Field.
Returns
ConstantField
A constant Field element equivalent to this Field element.
Example
const someField = Field(42);
someField.toConstant().assertEquals(someField); // Always trueInherited from
Field.toConstant
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:91
toFields()
toFields():
Field[]
This function is the implementation of Provable.toFields for the Field type.
The result will be always an array of length 1, where the first and only element equals the Field itself.
Returns
Field[]
A Field array of length 1 created from this Field.
Inherited from
Field.toFields
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:614
toJSON()
toJSON():
string
Serialize the Field to a JSON string, e.g. for printing. Trying to print a Field without this function will directly stringify the Field object, resulting in unreadable output.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the JSON string representation of the Field. Use the operation only during debugging.
Returns
string
A string equivalent to the JSON representation of the Field.
Example
const someField = Field(42);
console.log(someField.toJSON());Inherited from
Field.toJSON
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:635
toString()
toString():
string
Serialize the Field to a string, e.g. for printing. Trying to print a Field without this function will directly stringify the Field object, resulting in unreadable output.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the string representation of the Field. Use the operation only during debugging.
Returns
string
A string equivalent to the string representation of the Field.
Example
const someField = Field(42);
console.log(someField.toString());Inherited from
Field.toString
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:119
check()
staticcheck():void
This function is the implementation of Provable.check in Field type.
As any field element can be a Field, this function does not create any assertions, so it does nothing.
Returns
void
Inherited from
Field.check
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:594
empty()
staticempty():Field
Returns
Field
Inherited from
Field.empty
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:621
from()
staticfrom(x):Field
Parameters
• x: string | number | bigint | Field
Returns
Field
Inherited from
Field.from
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:56
fromBits()
staticfromBits(bits):Field
Convert a bit array into a Field element using little endian binary representation
The method throws if the given bits do not fit in a single Field element. In this case, no more than 254 bits are allowed because some 255 bit integers do not fit into a single Field element.
Important: If the given bits array is an array of booleans or Bool elements that all are constant, the resulting Field element will be a constant as well. Or else, if the given array is a mixture of constants and variables of Bool type, the resulting Field will be a variable as well.
Parameters
• bits: (boolean | Bool)[]
An array of Bool or boolean type.
Returns
Field
A Field element matching the little endian binary representation of the given bits array.
Inherited from
Field.fromBits
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:522
fromBytes()
staticfromBytes(bytes):Field
Coerce a new Field element using the little-endian representation of the given bytes array.
Note that the given bytes array may have at most 32 elements as the Field is a finite-field in the order of Field.ORDER.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the byte representation of the Field.
Parameters
• bytes: number[]
The bytes array to coerce the Field from.
Returns
Field
A new Field element created using the little-endian representation of the given bytes array.
Inherited from
Field.fromBytes
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:703
fromFields()
staticfromFields(fields):Field
Implementation of Provable.fromFields for the Field type.
Warning: This function is designed for internal use. It is not intended to be used by a zkApp developer.
Creates a Field from an array of Fields of length 1.
Parameters
• fields: Field[]
an array of length 1 serialized from Field elements.
Returns
Field
The first Field element of the given array.
Inherited from
Field.fromFields
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:588
fromJSON()
staticfromJSON(json):Field
Deserialize a JSON string containing a “field-like” value into a Field element.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the string representation of the Field.
Parameters
• json: string
the “field-like” value to coerce the Field from.
Returns
Field
A Field coerced from the given JSON string.
Inherited from
Field.fromJSON
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:661
fromValue()
staticfromValue(x):Field
Provable<Field>.fromValue()
Parameters
• x: string | number | bigint | Field
Returns
Field
Inherited from
Field.fromValue
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:606
random()
staticrandom():Field
A random Field element.
Returns
Field
A random Field element.
Example
console.log(Field.random().toBigInt()); // Run this code twice!Inherited from
Field.random
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:545
readBytes()
staticreadBytes<N>(bytes,offset): [Field,number]
Part of the Binable interface.
Warning: This function is for internal use. It is not intended to be used by a zkApp developer.
Type Parameters
• N extends number
Parameters
• bytes: number[]
• offset: NonNegativeInteger<N>
Returns
[Field, number]
Inherited from
Field.readBytes
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:692
sizeInFields()
staticsizeInFields():number
This function is the implementation of Provable.sizeInFields for the Field type.
Size of the Field type is 1, as it is the primitive type. This function returns a regular number, so you cannot use it to prove something on chain. You can use it during debugging or to understand the memory complexity of some type.
Returns
number
A number representing the size of the Field type in terms of Field type itself.
Example
console.log(Field.sizeInFields()); // Prints 1Inherited from
Field.sizeInFields
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:576
toAuxiliary()
statictoAuxiliary(): []
This function is the implementation of Provable.toAuxiliary for the Field type.
As the primitive Field type has no auxiliary data associated with it, this function will always return an empty array.
Returns
[]
Inherited from
Field.toAuxiliary
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:562
toBigint()
statictoBigint(x):bigint
Convert a Field element to a bigint.
Parameters
• x: Field
Returns
bigint
Inherited from
Field.toBigint
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:602
toBytes()
statictoBytes(value):number[]
Create an array of digits equal to the little-endian byte order of the given Field element.
Note that the array has always 32 elements as the Field is a finite-field in the order of Field.ORDER.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the byte representation of the Field.
Parameters
• value: Field
The Field element to generate the array of bytes of.
Returns
number[]
An array of digits equal to the little-endian byte order of the given Field element.
Inherited from
Field.toBytes
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:686
toFields()
statictoFields(value):Field[]
This function is the implementation of Provable.toFields for the Field type.
Static function to serializes a Field into an array of Field elements. This will be always an array of length 1, where the first and only element equals the given parameter itself.
Parameters
• value: Field
the Field element to cast the array from.
Returns
Field[]
A Field array of length 1 created from this Field.
Inherited from
Field.toFields
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:556
toInput()
statictoInput(value):object
Warning: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer.
This function is the implementation of ProvableExtended.toInput() for the Field type.
Parameters
• value: Field
The Field element to get the input array.
Returns
object
An object where the fields key is a Field array of length 1 created from this Field.
fields
fields:
Field[]
Inherited from
Field.toInput
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:672
toJSON()
statictoJSON(value):string
Serialize the given Field element to a JSON string, e.g. for printing. Trying to print a Field without this function will directly stringify the Field object, resulting in unreadable output.
Warning: This operation does not affect the circuit and can’t be used to prove anything about the JSON string representation of the Field. Use the operation only during debugging.
Parameters
• value: Field
The JSON string to coerce the Field from.
Returns
string
A string equivalent to the JSON representation of the given Field.
Example
const someField = Field(42);
console.log(Field.toJSON(someField));Inherited from
Field.toJSON
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:651
toValue()
statictoValue(x):bigint
Provable<Field>.toValue()
Parameters
• x: Field
Returns
bigint
Inherited from
Field.toValue
Defined in
node_modules/o1js/dist/node/lib/provable/field.d.ts:598