def sign_typed_message(self, domain_data: dict, message_types: dict, message_data: dict) -> Optional[SignedMessageData]
# 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..."
}
signed = account.sign_typed_message(domain_data, message_types, message_data)
if signed:
print(f"Message Hash: {signed.message_hash.hex()}")
print(f"Signer: {signed.signer}")
print(f"Signature: {signed.signature_data.signature.hex()}")