Skip to content

Instantly share code, notes, and snippets.

@SuperCipher
Created March 21, 2022 16:13
Show Gist options
  • Save SuperCipher/8095fde9d52ac8d13d38eb0364558006 to your computer and use it in GitHub Desktop.
Save SuperCipher/8095fde9d52ac8d13d38eb0364558006 to your computer and use it in GitHub Desktop.
signing recursive data structure EIP-712
def sign_seller_signature():
def sign_seller_signature(
contract,
sellers_signing_account: Account, # NOTE: Must be a eth_key account, not Brownie
seller_address,
seller_erc20_address,
seller_info,
):
name = "Ampleia"
version = contract.apiVersion()
# import pdb
#
# pdb.set_trace()
data = {
"types": {
"EIP712Domain": [
{"name": "name", "type": "string"},
{"name": "version", "type": "string"},
{"name": "chainId", "type": "uint256"},
{"name": "verifyingContract", "type": "address"},
],
"SellerERC721Addresses": [
{"name": "addr", "type": "address"},
],
"SellerInfo": [
{"name": "addr", "type": "address"},
{"name": "erc20_address", "type": "address"},
{
"name": "seller_erc721_addresses",
"type": "SellerERC721Addresses",
},
],
},
"domain": {
"name": name,
"version": version,
"chainId": chain_id(),
"verifyingContract": str(contract),
},
"primaryType": "SellerInfo",
"message": {
"addr": seller_address,
"erc20_address": seller_erc20_address,
"seller_erc721_addresses": {
"addr": "0x0FD4C4Ef9Bbe66217Eb790E5D42A5cC103eeFC90",
},
},
}
seller_data = encode_structured_data(data)
return sellers_signing_account.sign_message(seller_data).signature
return sign_seller_signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment