pybotters.helpers.hyperliquid

Signing helpers for Hyperliquid API.

  1. Construct EIP-712 typed data

    Use construct_l1_action() or construct_user_signed_action()

  2. Sign EIP-712 typed data

    Use sign_typed_data()

pybotters.helpers.hyperliquid.construct_l1_action(action: Mapping[str, object], nonce: int, is_mainnet: bool, vault_address: str | None = None, expires_after: int | None = None) tuple[EIP712Domain, Mapping[str, Sequence[MessageType]], PhantomAgentMessage]

Construct EIP-712 typed data for Hyperliquid L1 action.

パラメータ:
  • action -- Hyperqilid action object

  • nonce -- nonce for signing

  • is_mainnet -- True for mainnet, False for testnet

  • vault_address -- (optional) vault address

戻り値:

tuple[EIP712Domain, MessageTypes, PhantomAgentMessage]

pybotters.helpers.hyperliquid.construct_user_signed_action(action: Mapping[str, object], message_types: Mapping[str, Sequence[MessageType]] | None = None) tuple[EIP712Domain, Mapping[str, Sequence[MessageType]], Mapping[str, object]]

Construct EIP-712 typed data for Hyperliquid user signed action.

パラメータ:
  • action -- Hyperqilid action object

  • message_types -- (optional) message types. If not provided, it will be generated by generate_message_types().

戻り値:

tuple[EIP712Domain, MessageTypes, PhantomAgentMessage]

pybotters.helpers.hyperliquid.sign_typed_data(private_key: str, domain_data: EIP712Domain, message_types: Mapping[str, Sequence[MessageType]], message_data: Mapping[str, object]) Signature

Sign EIP-712 typed data with private key.

パラメータ:
  • private_key -- Your API wallet private key

  • domain_data -- EIP-712 domain data

  • message_types -- EIP-712 message types

  • message_data -- EIP-712 message data

戻り値:

Signature

pybotters.helpers.hyperliquid.generate_message_types(message_data: Mapping[str, object]) Mapping[str, Sequence[MessageType]]

Generate message types from message data.

パラメータ:

message_data -- Hyperqilid message data

戻り値:

MessageTypes

Infer Solidity Types from Python types. This is a basic conversion and not complete.

pybotters.helpers.hyperliquid.get_timestamp_ms() int

Get current timestamp in milliseconds that can be used as time or nonce.

戻り値:

int

Functions

construct_l1_action(action, nonce, is_mainnet)

Construct EIP-712 typed data for Hyperliquid L1 action.

construct_user_signed_action(action[, ...])

Construct EIP-712 typed data for Hyperliquid user signed action.

generate_message_types(message_data)

Generate message types from message data.

get_timestamp_ms()

Get current timestamp in milliseconds that can be used as time or nonce.

sign_typed_data(private_key, domain_data, ...)

Sign EIP-712 typed data with private key.

Classes

EIP712Domain

TypedDict for EIP-712 domain data.

MessageType

TypedDict for EIP-712 message type.

PhantomAgentMessage

TypedDict for Phantom Agent message.

Signature

TypedDict for signature.