Skip to main content
Version: 11.x

Function: getAbiVersion()

getAbiVersion(abi): 0 | 1 | 2

Defined in: src/utils/calldata/parser/index.ts:95

Get the format of an abi, which tells which parser reads it: AbiParser0, AbiParser1 or AbiParser2. It is the shape of the abi, not the version of Cairo.

  • 0: a Cairo 0 abi.
  • 1: a Cairo 1 abi with its functions at the top level. It comes from a Cairo V1 contract, or from a Cairo V2 contract with no interface entry: one with no external function, or one that declares its functions one by one with #[external(v0)].
  • 2: a Cairo 1 abi with interface entries, from a Cairo V2 contract written with interfaces.

Parameters​

abi​

Abi

Returns​

0 | 1 | 2

the format of the abi

Example​

// Example 1: Return ABI version 2
const version = getAbiVersion([getInterfaceAbi()]);
// version === 2

// Example 2: Return ABI version 1
const version = getAbiVersion([getInterfaceAbi('core::bool')]);
// version === 1

// Example 3: Return ABI version 0
const version = getAbiVersion([getInterfaceAbi('felt')]);
// version === 0