Skip to main content
Version: Next

Class: CairoFixedArray

Constructors​

constructor​

• new CairoFixedArray(content, arrayType): CairoFixedArray

Create an instance representing a Cairo fixed Array.

Parameters​

NameTypeDescription
contentany[]JS array representing a Cairo fixed array.
arrayTypestringCairo fixed array type.

Returns​

CairoFixedArray

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:19

Properties​

content​

• Readonly content: any[]

JS array representing a Cairo fixed array.

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:7


arrayType​

• Readonly arrayType: string

Cairo fixed array type.

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:12

Methods​

getFixedArraySize​

â–¸ getFixedArraySize(type): number

Retrieves the array size from the given type string representing a Cairo fixed array.

Parameters​

NameTypeDescription
typestringThe Cairo fixed array type.

Returns​

number

The array size.

Example

const result = CairoFixedArray.getFixedArraySize("[core::integer::u32; 8]");
// result = 8

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:56


getFixedArrayType​

â–¸ getFixedArrayType(type): string

Retrieve the Cairo content type from a Cairo fixed array type.

Parameters​

NameTypeDescription
typestringThe type string.

Returns​

string

The fixed-array type.

Example

const result = CairoFixedArray.getFixedArrayType("[core::integer::u32; 8]");
// result = "core::integer::u32"

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:87


compile​

â–¸ compile(input): Object

Create an object from a Cairo fixed array. Be sure to have an array length conform to the ABI. To be used with CallData.compile().

Parameters​

NameTypeDescription
inputany[]JS array representing a Cairo fixed array.

Returns​

Object

a specific struct representing a fixed Array.

Example

const result = CairoFixedArray.compile([10,20,30]);
// result = { '0': 10, '1': 20, '2': 30 }

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:120


isTypeFixedArray​

â–¸ isTypeFixedArray(type): boolean

Checks if the given Cairo type is a fixed-array type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • true if the type is a fixed array type, false otherwise.
const result = CairoFixedArray.isTypeFixedArray("[core::integer::u32; 8]");
// result = true

#### Defined in

[src/utils/cairoDataTypes/fixedArray.ts:151](https://github.com/starknet-io/starknet.js/blob/develop/src/utils/cairoDataTypes/fixedArray.ts#L151)

___

### getFixedArraySize

â–¸ **getFixedArraySize**(): `number`

Retrieves the Cairo fixed array size from the CairoFixedArray instance.

#### Returns

`number`

The fixed array size.

**`Example`**

```typescript
const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.getFixedArraySize();
// result = 3

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:73


getFixedArrayType​

â–¸ getFixedArrayType(): string

Retrieve the Cairo content type of the Cairo fixed array.

Returns​

string

The fixed-array content type.

Example

const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.getFixedArrayType();
// result = "core::integer::u32"

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:104


compile​

â–¸ compile(): Object

Generate an object from the Cairo fixed array instance. To be used with CallData.compile().

Returns​

Object

a specific struct representing a fixed array.

Example

const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.compile();
// result = { '0': 10, '1': 20, '2': 30 }

Defined in​

src/utils/cairoDataTypes/fixedArray.ts:138