Cairo#

starknet_py.cairo.felt.encode_shortstring(text: str) int#

A function which encodes short string value (at most 31 characters) into cairo felt (MSB as first character)

Parameters:

text – A short string value in python

Returns:

Short string value encoded into felt

starknet_py.cairo.felt.decode_shortstring(value: int) str#

A function which decodes a felt value to short string (at most 31 characters)

Parameters:

value – A felt value

Returns:

Decoded string which is corresponds to that felt

TypeParser#

exception starknet_py.cairo.type_parser.UnknownCairoTypeError#

Error thrown when TypeParser finds type that was not declared prior to parsing.

__init__(type_name: str)#
class starknet_py.cairo.type_parser.TypeParser#

Low level utility class for parsing Cairo types that can be used in external methods.

__init__(defined_types: Dict[str, StructType])#

TypeParser constructor.

Parameters:

defined_types – dictionary containing all defined types. For now, they can only be structures.

parse_inline_type(type_string: str) CairoType#

Inline type is one that can be used inline, for instance as return type. For instance (a: Uint256, b: felt*, c: (felt, felt)). Structure can only be referenced in inline type, can’t be defined this way.

Parameters:

type_string – type to parse.