Skip to content

flashbots/rpc-endpoint

Repository files navigation

Flashbots Protect RPC Endpoint

Test status standard-readme compliant Discord

This repository contains code for a server which can be used as an RPC endpoint in popular Ethereum wallets.

The endpoint is live at https://rpc.flashbots.net/

It does two basic things:

  • It receives JSON-RPC requests, proxies those to a node, and responds with the result of the proxied request.
  • On receiving an eth_sendRawTransaction call which has data and is not on whitelisted methods, the call is sent to the Flashbots relay as a private transaction, and submitted as bundles for up to 25 blocks.

There are a few key benefits to using the Flashbots RPC endpoint:

  • Frontrunning protection: your transaction will not be seen by hungry sandwich bots in the public mempool.
  • No failed transactions: your transaction will only be mined if it doesn't include any reverts, so you don't pay for failed transactions. Note: your transaction could be uncled, emitted to the mempool, and then included on-chain.
  • Priority in blocks: transactions sent via Flashbots are mined at the top of blocks, giving them priority.

Privacy notice: rpc-endpoint does not track, store or log any kind of user information (i.e. IP, location, etc.).

Transaction Status Check

If a transaction is sent to the Flashbots relay instead of the public mempool, you cannot see the status on Etherscan or other explorers. Flashbots provides a Protect Transaction API to get the status of these private transactions: https://protect.flashbots.net/

Transaction Frontrunning Protection Evaluation Rules

Not all transactions need frontrunning protection, and in fact some transactions cannot be sent to Flashbots at all. To reflect this we evaluate transactions in two ways:

  • Does the transaction use more than 42,000 gas? If it doesn't then the Flashbots Relay will reject it, and we're not aware of use cases that use such low gas that need frontrunning protection. Thus, we send low gas transactions to the mempool.
  • Does the transaction call one of a few whitelisted functions, such as an ERC20 approval, that don't need frontrunning protection? If so then we send it to the mempool.

We're open to new ways of evaluating what needs frontrunning protection and welcome PRs to this end.

Usage

To send your transactions through the Flashbots Protect RPC please refer to the quick-start guide.

To run the server, run the following command:

go run cmd/server/main.go -redis REDIS_URL -signingKey ETH_PRIVATE_KEY -proxy PROXY_URL

# For development, you can use built-in redis and create a random signing key
go run cmd/server/main.go -redis dev -signingKey dev -proxy PROXY_URL

# You can use the DEBUG_DONT_SEND_RAWTX to skip sending transactions anywhere (useful for local testing):
DEBUG_DONT_SEND_RAWTX=1 go run cmd/server/main.go -redis dev -signingKey dev -proxy PROXY_URL

Example Single request:

curl localhost:9000 -f -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}'

Contributing

Flashbots is a research and development collective working on mitigating the negative externalities of decentralized economies. We contribute with the larger free software community to illuminate the dark forest.

You are welcome here <3.

Send a pull request

  • Your proposed changes should be first described and discussed in an issue.
  • Every pull request should be small and represent a single change. If the problem is complicated, split it in multiple issues and pull requests.
  • Every pull request should be covered by unit/e2e tests.

We appreciate your contributions <3

Please install staticcheck (go install honnef.co/go/tools/cmd/staticcheck@master) and run make lint before submitting a PR.

Security

If you find a security vulnerability on this project or any other initiative related to Flashbots, please let us know sending an email to [email protected].

License

The code in this project is free software under the MIT license.


Made with ☀️ by the ⚡🤖 collective.