Skip to main content
Version: 8.6.0

Namespace: cairo

Functions​

isCairo1Abi​

▸ isCairo1Abi(abi): boolean

Test if an ABI comes from a Cairo 1 contract

Parameters​

NameTypeDescription
abiAbirepresenting the interface of a Cairo contract

Returns​

boolean

TRUE if it is an ABI from a Cairo1 contract

Example

const isCairo1: boolean = isCairo1Abi(myAbi: Abi);

Defined in​

src/utils/calldata/cairo.ts:173


isTypeNonZero​

▸ isTypeNonZero(type): boolean

Checks if the given type is a NonZero type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

true if the type is NonZero type, false otherwise.

Example

const result = cairo.isTypeNonZero('core::zeroable::NonZero::<u8>');
//result = true

Defined in​

src/utils/calldata/cairo.ts:192


getAbiContractVersion​

▸ getAbiContractVersion(abi): ContractVersion

Return ContractVersion (Abi version) based on Abi or undefined for unknown version

Parameters​

NameType
abiAbi

Returns​

ContractVersion

string

Defined in​

src/utils/calldata/cairo.ts:202


felt​

▸ felt(it): string

Create felt Cairo type (cairo type helper)

Parameters​

NameType
itBigNumberish

Returns​

string

format: felt-string

Defined in​

src/utils/calldata/cairo.ts:271


isLen​

▸ isLen(name): boolean

Checks if the given name ends with "_len".

Parameters​

NameTypeDescription
namestringThe name to be checked.

Returns​

boolean

  • True if the name ends with "_len", false otherwise.

Defined in​

src/utils/calldata/cairo.ts:26


isTypeFelt​

▸ isTypeFelt(type): boolean

Checks if a given type is felt.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • True if the type is felt, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:33


isTypeArray​

▸ isTypeArray(type): boolean

Checks if the given type is an array type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • true if the type is an array type, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:40


isTypeTuple​

▸ isTypeTuple(type): boolean

Checks if the given type is a tuple type.

Parameters​

NameTypeDescription
typestringThe type to be checked.

Returns​

boolean

  • true if the type is a tuple type, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:51


isTypeNamedTuple​

▸ isTypeNamedTuple(type): boolean

Checks whether a given type is a named tuple.

Parameters​

NameTypeDescription
typestringThe type to be checked.

Returns​

boolean

  • True if the type is a named tuple, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:58


isTypeStruct​

▸ isTypeStruct(type, structs): boolean

Checks if a given type is a struct.

Parameters​

NameTypeDescription
typestringThe type to check for existence.
structsAbiStructsThe collection of structs to search in.

Returns​

boolean

  • True if the type exists in the structs, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:66


isTypeEnum​

▸ isTypeEnum(type, enums): boolean

Checks if a given type is an enum.

Parameters​

NameTypeDescription
typestringThe type to check.
enumsAbiEnumsThe enumeration to search in.

Returns​

boolean

  • True if the type exists in the enumeration, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:74


isTypeOption​

▸ isTypeOption(type): boolean

Determines if the given type is an Option type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • True if the type is an Option type, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:81


isTypeResult​

▸ isTypeResult(type): boolean

Checks whether a given type starts with 'core::result::Result::'.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • True if the type starts with 'core::result::Result::', false otherwise.

Defined in​

src/utils/calldata/cairo.ts:88


isTypeUint​

▸ isTypeUint(type): boolean

Checks if the given value is a valid Uint type.

Parameters​

NameTypeDescription
typestringThe value to check.

Returns​

boolean

  • Returns true if the value is a valid Uint type, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:95


isTypeInt​

▸ isTypeInt(type): boolean

Checks if the given value is a valid Int type.

Parameters​

NameTypeDescription
typestringThe value to check.

Returns​

boolean

  • Returns true if the value is a valid Int type, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:102


isTypeUint256​

▸ isTypeUint256(type): boolean

Checks if the given type is uint256.

Parameters​

NameTypeDescription
typestringThe type to be checked.

Returns​

boolean

  • Returns true if the type is uint256, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:110


isTypeLiteral​

▸ isTypeLiteral(type): boolean

Checks if the given type is a literal type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • True if the type is a literal type, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:117


isTypeBool​

▸ isTypeBool(type): boolean

Checks if the given type is a boolean type.

Parameters​

NameTypeDescription
typestringThe type to be checked.

Returns​

boolean

  • Returns true if the type is a boolean type, otherwise false.

Defined in​

src/utils/calldata/cairo.ts:124


isTypeContractAddress​

▸ isTypeContractAddress(type): boolean

Checks if the provided type is equal to 'core::starknet::contract_address::ContractAddress'.

Parameters​

NameTypeDescription
typestringThe type to be checked.

Returns​

boolean

  • true if the type matches 'core::starknet::contract_address::ContractAddress', false otherwise.

Defined in​

src/utils/calldata/cairo.ts:130


isTypeEthAddress​

▸ isTypeEthAddress(type): boolean

Determines if the given type is an Ethereum address type.

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • Returns true if the given type is 'core::starknet::eth_address::EthAddress', otherwise false.

Defined in​

src/utils/calldata/cairo.ts:137


isTypeU96​

▸ isTypeU96(type): boolean

Checks if the given type is equal to the u96 type

Parameters​

NameTypeDescription
typestringThe type to check.

Returns​

boolean

  • True if the given type is equal to u96, false otherwise.

Defined in​

src/utils/calldata/cairo.ts:145


isTypeSecp256k1Point​

▸ isTypeSecp256k1Point(type): boolean

Parameters​

NameType
typestring

Returns​

boolean

Defined in​

src/utils/calldata/cairo.ts:148


isCairo1Type​

▸ isCairo1Type(type): boolean

Parameters​

NameType
typestring

Returns​

boolean

Defined in​

src/utils/calldata/cairo.ts:150


getArrayType​

▸ getArrayType(type): string

Retrieves the array type from the given type string.

Works also for core::zeroable::NonZero type.

Parameters​

NameTypeDescription
typestringThe type string.

Returns​

string

  • The array type.

Defined in​

src/utils/calldata/cairo.ts:158


uint256​

▸ uint256(it): Uint256

Create Uint256 Cairo type (helper for common struct type)

Parameters​

NameType
itBigNumberish

Returns​

Uint256

Example

uint256('892349863487563453485768723498');

Defined in​

src/utils/calldata/cairo.ts:239


uint512​

▸ uint512(it): Uint512

Create Uint512 Cairo type (helper for common struct type)

Parameters​

NameTypeDescription
itBigNumberishBigNumberish representation of a 512 bits unsigned number

Returns​

Uint512

Uint512 struct

Example

uint512('345745685892349863487563453485768723498');

Defined in​

src/utils/calldata/cairo.ts:252


tuple​

▸ tuple(...args): Record<number, boolean | object | BigNumberish>

Create unnamed tuple Cairo type (helper same as common struct type)

Parameters​

NameType
...args(boolean | object | BigNumberish)[]

Returns​

Record<number, boolean | object | BigNumberish>

Example

tuple(1, '0x101', 16);

Defined in​

src/utils/calldata/cairo.ts:263