Skip to main content
Version: Next

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:169


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:188


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:198


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:264


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:23


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:30


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:37


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:47


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:54


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:62


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:70


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:77


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:84


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:91


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:99


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:106


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:113


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:119


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:127


isTypeBytes31

isTypeBytes31(type): boolean

Checks if the given type is 'core::bytes_31::bytes31'.

Parameters

NameTypeDescription
typestringThe type to check.

Returns

boolean

  • True if the type is 'core::bytes_31::bytes31', false otherwise.

Defined in

src/utils/calldata/cairo.ts:135


isTypeByteArray

isTypeByteArray(type): boolean

Checks if the given type is equal to the 'core::byte_array::ByteArray'.

Parameters

NameTypeDescription
typestringThe type to check.

Returns

boolean

  • True if the given type is equal to 'core::byte_array::ByteArray', false otherwise.

Defined in

src/utils/calldata/cairo.ts:142


isTypeSecp256k1Point

isTypeSecp256k1Point(type): boolean

Parameters

NameType
typestring

Returns

boolean

Defined in

src/utils/calldata/cairo.ts:143


isCairo1Type

isCairo1Type(type): boolean

Parameters

NameType
typestring

Returns

boolean

Defined in

src/utils/calldata/cairo.ts:145


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:153


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:232


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:245


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:256