Python zero_ex.middlewares¶
Web3 middlewares for 0x applications.
zero_ex.middlewares.local_message_signer¶
Middleware that captures all ‘eth_sign’ requests to the JSON-RPC-Server.
An adaptation of the signing middleware from web3.py. This middleware intercepts all ‘eth_sign’ requests to an ethereum JSON RPC-Server and signs messages with a local private key.
-
zero_ex.middlewares.local_message_signer.construct_local_message_signer(private_key_or_account)[source]¶ Construct a local messager signer middleware.
- Parameters
private_key_or_account (
Union[LocalAccount,PrivateKey,str,List[Union[LocalAccount,PrivateKey,str]],Tuple[Union[LocalAccount,PrivateKey,str]],Set[Union[LocalAccount,PrivateKey,str]]]) –a single private key or a tuple, list, or set of private keys. Keys can be any of the following formats:
An
eth_account.LocalAccountobjectAn
eth_keys.PrivateKeyobjectA raw private key as a hex
stringor asbytes
- Returns
callable local_message_signer_middleware
>>> private_key=( ... "f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d" ... ) >>> from web3 import Web3, HTTPProvider >>> Web3( ... HTTPProvider("https://mainnet.infura.io/v3/API_KEY") ... ).middleware_onion.add( ... construct_local_message_signer(private_key) ... )