flashbots / web3-flashbots

Web3.py plugin for using Flashbots' bundle APIs
https://pypi.org/project/flashbots/
MIT License
405 stars 213 forks source link

Setting custom headers for 3rd party relays #79

Closed JustAnotherC0der closed 1 year ago

JustAnotherC0der commented 1 year ago

Hello I am trying to set a custom header via the flashbots provider but can't seem to figure out where to set it. I see in the flashbots provider it takes a header in put here

    headers = self.get_request_headers() | {
        "X-Flashbots-Signature": f"{self.signature_account.address}:{signed_message.signature.hex()}"

but I cannot find where get_request_headers() is looking for the header data. If someone has an example using the flashbots wrapper with custom headers, please drop an example if you can!

Thanks

JustAnotherC0der commented 1 year ago

Turns out I didn't look hard enough. The header will be set when starting the HTTPProvider, not when initializing flashbot.

For anyone looking for this answer:

some_kwargs = { 'headers': {"Authorization": "Token"}, "timeout": 30 } web3fb = Web3(HTTPProvider(NODE_URL, request_kwargs=some_kwargs))