Skip to main content
Version: 5.19.5

Class: CallData

Constructors​

constructor​

• new CallData(abi)

Parameters​

NameType
abiAbi

Defined in​

src/utils/calldata/index.ts:47

Properties​

abi​

• abi: Abi

Defined in​

src/utils/calldata/index.ts:39


parser​

• parser: AbiParserInterface

Defined in​

src/utils/calldata/index.ts:41


structs​

• Protected Readonly structs: AbiStructs

Defined in​

src/utils/calldata/index.ts:43


enums​

• Protected Readonly enums: AbiEnums

Defined in​

src/utils/calldata/index.ts:45

Methods​

compile​

â–¸ Static compile(rawArgs): Calldata

Compile contract callData without abi

Parameters​

NameTypeDescription
rawArgsRawArgsRawArgs representing cairo method arguments or string array of compiled data

Returns​

Calldata

Calldata

Defined in​

src/utils/calldata/index.ts:161


getAbiStruct​

â–¸ Static getAbiStruct(abi): AbiStructs

Helper to extract structs from abi

Parameters​

NameTypeDescription
abiAbiAbi

Returns​

AbiStructs

AbiStructs - structs from abi

Defined in​

src/utils/calldata/index.ts:279


getAbiEnum​

â–¸ Static getAbiEnum(abi): AbiEnums

Helper to extract enums from abi

Parameters​

NameTypeDescription
abiAbiAbi

Returns​

AbiEnums

AbiEnums - enums from abi

Defined in​

src/utils/calldata/index.ts:296


toCalldata​

â–¸ Static toCalldata(rawCalldata?): Calldata

Helper: Compile HexCalldata | RawCalldata | RawArgs

Parameters​

NameTypeDefault valueDescription
rawCalldataRawArgs[]HexCalldata | RawCalldata | RawArgs

Returns​

Calldata

Calldata

Defined in​

src/utils/calldata/index.ts:315


toHex​

â–¸ Static toHex(raw?): HexCalldata

Helper: Convert raw to HexCalldata

Parameters​

NameTypeDefault valueDescription
rawRawArgs[]HexCalldata | RawCalldata | RawArgs

Returns​

HexCalldata

HexCalldata

Defined in​

src/utils/calldata/index.ts:324


validate​

â–¸ validate(type, method, args?): void

Validate arguments passed to the method as corresponding to the ones in the abi

Parameters​

NameTypeDefault valueDescription
typeValidateTypeundefinedValidateType - type of the method
methodstringundefinedstring - name of the method
argsArgsOrCalldata[]ArgsOrCalldata - arguments that are passed to the method

Returns​

void

Defined in​

src/utils/calldata/index.ts:60


compile​

â–¸ compile(method, argsCalldata): Calldata

Compile contract callData with abi Parse the calldata by using input fields from the abi for that method

Example

const calldata = myCallData.compile('constructor', ['0x34a', [1, 3n]]);
const calldata2 = myCallData.compile('constructor', { list: [1, 3n], balance: '0x34' }); // wrong order is valid

Parameters​

NameTypeDescription
methodstringstring - method name
argsCalldataRawArgs-

Returns​

Calldata

Calldata - parsed arguments in format that contract is expecting

Defined in​

src/utils/calldata/index.ts:113


parse​

â–¸ parse(method, response): Result

Parse elements of the response array and structuring them into response object

Parameters​

NameTypeDescription
methodstringstring - method name
responsestring[]string[] - response from the method

Returns​

Result

Result - parsed response corresponding to the abi

Defined in​

src/utils/calldata/index.ts:245


format​

â–¸ format(method, response, format): Result

Format cairo method response data to native js values based on provided format schema

Parameters​

NameTypeDescription
methodstringstring - cairo method name
responsestring[]string[] - cairo method response
formatobjectobject - formatter object schema

Returns​

Result

Result - parsed and formatted response object

Defined in​

src/utils/calldata/index.ts:269