Poseidon Docs
SeaverseGithub
  • 入门
    • 简介
    • 安装
    • 示例
    • 注意事项
    • 更新日志
      • v2.0.1
      • v2.0.0
  • EVM
    • (DataClass)
      • ChainInformationData
      • BlockInformationData
      • TransactionReceiptData
      • SignatureData
      • SignedMessageData
    • Chain
      • __init__
      • get_chain_information
      • get_block_information
      • get_transaction_receipt_by_hash
      • get_transaction_receipt_by_block_id_and_index
      • get_balance
      • get_code
      • get_storage
      • dump_storage
    • Account
      • __init__
      • set_need_confirm_before_send_transaction
      • get_self_balance
      • send_transaction
      • send_transaction_by_eip1559
      • deploy_contract
      • sign_message_string
      • sign_message_raw_hash
      • sign_message_hash
      • sign_typed_message
    • Contract
      • __init__
      • call_function
      • call_function_with_parameters
      • read_only_call_function
      • encode_function_calldata
      • decode_function_calldata
    • Utils
      • set_solidity_version
      • compile_solidity_contract
      • import_contract_abi
      • generate_new_account
      • generate_account_from_mnemonic
      • calculate_create_case_contract_address
      • calculate_create2_case_contract_address
      • generate_signature_data_with_signature
      • generate_signature_data_with_rsv
      • recover_message_string
      • recover_message_raw_hash
      • recover_message_hash
      • recover_typed_message
      • convert_equivalent_signature
      • assembly_to_bytecode_legacy
      • bytecode_to_assembly_legacy
  • Solana
    • (stay tuned)
  • TON
    • (stay tuned)
  • Sui
    • (stay tuned)
由 GitBook 提供支持
在本页
  • 方法定义
  • 参数说明
  • 返回值
  • 示例代码

这有帮助吗?

在GitHub上编辑
  1. EVM
  2. Utils

recover_typed_message

通过结构化消息数据和签名还原出签署者的账户地址。

方法定义

@staticmethod
def recover_typed_message(domain_data: dict, message_types: dict, message_data: dict, signature: HexBytes) -> Optional[SignedMessageData]

参数说明

参数
类型
说明

domain_data

dict

域数据

message_types

dict

消息类型定义

message_data

dict

消息数据

signature

HexBytes

签名

返回值

返回 SignedMessageData 对象,包含以下字段:

字段
类型
说明

message_hash

HexBytes

消息哈希

message

str

原始消息

signer

ChecksumAddress

签名者地址

signature_data

SignatureData

签名数据

示例代码

# 恢复 EIP-712 结构化数据签名者
domain_data = {
    "name": "MyDApp",
    "version": "1",
    "chainId": 1,
    "verifyingContract": "0x..."
}

message_types = {
    "Person": [
        {"name": "name", "type": "string"},
        {"name": "wallet", "type": "address"}
    ]
}

message_data = {
    "name": "Bob",
    "wallet": "0x..."
}

signature = HexBytes("0x...")  # 65 字节的签名
signed_data = Utils.recover_typed_message(domain_data, message_types, message_data, signature)
if signed_data:
    print(f"Signer: {signed_data.signer}")
上一页recover_message_hash下一页convert_equivalent_signature

最后更新于7个月前

这有帮助吗?