TypedData#

class starknet_py.utils.typed_data.TypedData#

Dataclass representing a TypedData object

types: Dict[str, List[Parameter]]#
primary_type: str#
domain: Domain#
message: dict#
static from_dict(data: TypedDataDict) TypedData#

Create TypedData dataclass from dictionary.

Parameters:

data – TypedData dictionary.

Returns:

TypedData dataclass instance.

to_dict() dict#

Create TypedData dictionary from dataclass.

Returns:

TypedData dictionary.

type_hash(type_name: str) int#

Calculate the hash of a type name.

Parameters:

type_name – Name of the type.

Returns:

Hash of the type name.

struct_hash(type_name: str, data: dict) int#

Calculate the hash of a struct.

Parameters:
  • type_name – Name of the type.

  • data – Data defining the struct.

Returns:

Hash of the struct.

message_hash(account_address: int) int#

Calculate the hash of the message.

Parameters:

account_address – Address of an account.

Returns:

Hash of the message.

Parameter#

class starknet_py.utils.typed_data.Parameter#

Parameter(name: str, type: str)

name: str#
type: str#

StandardParameter#

class starknet_py.utils.typed_data.StandardParameter#

StandardParameter(name: str, type: str)

name: str#
type: str#

EnumParameter#

class starknet_py.utils.typed_data.EnumParameter#

EnumParameter(name: str, contains: str)

type: str = 'enum'#
contains: str#

MerkleTreeParameter#

class starknet_py.utils.typed_data.MerkleTreeParameter#

MerkleTreeParameter(name: str, contains: str)

type: str = 'merkletree'#
contains: str#

Domain#

class starknet_py.utils.typed_data.Domain#

Dataclass representing a domain object (StarkNetDomain, StarknetDomain)

name: str#
version: str#
chain_id: str | int#
revision: Revision | None = None#
static from_dict(data: DomainDict) Domain#

Create Domain dataclass from dictionary.

Parameters:

data – Domain dictionary.

Returns:

Domain dataclass instance.

to_dict() dict#

Create Domain dictionary from dataclass.

Returns:

Domain dictionary.

BasicType#

class starknet_py.utils.typed_data.BasicType#

An enumeration.

FELT = 'felt'#
SELECTOR = 'selector'#
MERKLE_TREE = 'merkletree'#
ENUM = 'enum'#
SHORT_STRING = 'shortstring'#
STRING = 'string'#
CONTRACT_ADDRESS = 'ContractAddress'#
CLASS_HASH = 'ClassHash'#
BOOL = 'bool'#
U128 = 'u128'#
I128 = 'i128'#
TIMESTAMP = 'timestamp'#

PresetType#

class starknet_py.utils.typed_data.PresetType#

An enumeration.

U256 = 'u256'#
TOKEN_AMOUNT = 'TokenAmount'#
NFT_ID = 'NftId'#