Giter Site home page Giter Site logo

searcher-sponsored-tx's Introduction

searcher-sponsored-tx

This repository contains a simple Flashbots "searcher" for submitting a transaction from an executor account, but paying for the transaction from a sponsor account. This is accomplished by submitting a Flashbots transaction bundle, with the first "sponsor" transaction paying the "executor" wallet in ETH, followed by a series of executor transactions that spend this newly received ETH on gas fees.

We hope you will use this repository as an example of how to integrate Flashbots into your own Flashbot searcher (bot). For more information, see the Flashbots Searcher Quick Start

Use case

The use case for this multi-transaction setup is to make calls from an account that has a compromised private key. Since transferring in any ETH to this compromised wallet will immediately be swept by bots that monitor that account, transferring in funds will also give any attacker the ability to withdraw tokens that are held by that account.

Using this searcher, you can create a bundle of transaction that execute against the compromised account, spending ETH that was received in the same block.

With the activation of EIP-1559, the old method of using gasPrice = 0 is no longer functional. Transactions must pay at least baseFee.

Environment Variables

  • ETHEREUM_RPC_URL - Ethereum RPC endpoint. Can not be the same as FLASHBOTS_RPC_URL
  • PRIVATE_KEY_EXECUTOR - Private key for the compromised Ethereum EOA that owns assets that needs to be transferred
  • PRIVATE_KEY_SPONSOR - Private key for an account that has ETH that will be used to fund the miner for the "ZERO_GAS" transactions
  • RECIPIENT - Ethereum EOA to receive assets from ZERO_GAS account
  • FLASHBOTS_RELAY_SIGNING_KEY - Optional param, private key used to sign messages to Flashbots to establish reputation of profitability

Setting Miner Reward

Inside src/index.ts is :

const PRIORITY_GAS_PRICE = GWEI.mul(31)

This is the priority fee, on top of baseFee, sent to the miner for all transactions in the bundle, including the sponsor-funding transaction. All transactions use the same gasPrice, with no coinbase transfers in any transaction. In the case of a block re-organization, hopefully all transactions will appear in the next block as well, preventing sweeper bots from gaining access to the incoming ETH before it is spent on gas fees.

Selecting a different "engine"

This system can operate against different protocols by swapping a new "engine" class that adheres to "Base" functionality in the main() function. Available engines:

  • TransferERC20
  • CryptoKitties
  • Approval721

An engine accepts relevant parameters during construction and provides functions to retrieve transaction descriptions to be passed in to Flashbots. Selecting and configuring a different engine requires directly modifying the source, uncommenting the engine and setting the necessary variables.

Usage

$ npm install
$ PRIVATE_KEY_EXECUTOR=__COMPROMISED_PRIVATE_KEY__ \
    PRIVATE_KEY_SPONSOR=__FUNDED_PRIVATE_KEY__ \
    RECIPIENT=__ADDRESS_THAT_RECEIVES_ASSETS__ \
    FLASHBOTS_SECRET=__YOUR_PERSONAL_SECRET__ \
      npm run start

searcher-sponsored-tx's People

Contributors

carboclanc avatar epheph avatar kendricktan avatar obadiaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

searcher-sponsored-tx's Issues

can not find name 'TransferERC20'

at index.ts
// ======= UNCOMMENT FOR ERC20 TRANSFER ==========
const tokenAddress = "0xd565b7225160a14b45953fde0715d2a0916*";
const engine: Base = new TransferERC20(provider, walletExecutor.address, RECIPIENT, tokenAddress);
// ======= UNCOMMENT FOR ERC20 TRANSFER ==========

I got an error: can not find name 'TransferERC20'

HELP pls

Not working long time. Please- tell what my problem[2023-03-12T17:46:56.206Z] C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\logger\src.ts\index.ts:213
const error: any = new Error(message);
^
[2023-03-12T17:46:56.207Z] Error: bad response (status=400, headers={"date":"Sun, 12 Mar 2023 17:46:56 GMT","content-type":"application/json","content-length":"32","connection":"close","x-amzn-requestid":"34b925c2-1442-4522-a216-d25eb797401a","x-amz-apigw-id":"BrdykG7PCYcF-cg=","vary":"Origin","x-amzn-trace-id":"Root=1-640e1010-243b116c1b0be41e1043538f;Sampled=0"}, body="{"error":"unable to decode txs"}", requestBody="{"method":"eth_callBundle","params":[{"txs":["0xf86d8201a985078eedc5f28252089403567a339b9586e3f0b161f2df6ecdfa43a6921b87063988f836365a801ca0f1b6a34d336d5c080cb5b6a15997d2ca00ce901a336d54a17a051e2ab5954747a0412f16259bb1bb844e8ef52d26e4bc51135c16abf47344ba1a7bb95f7395ab13","0xf8ab82075b85078eedc5f282d2d594795dbf627484f8248d3d6c09c309825c1563e87380b844a9059cbb0000000000000000000000001eba3256bbda2ca07765bd06c33a4efbaa553631000000000000000000000000000000000000000000000000016272cc7e5cfc581ba0ab104947c3f1da75ffd5e85b3b896c6535bf611b21f67a4c647df64eb9209c5ca04a733f0f4b99cfb783c37e1262e70081f8c7bbbe603d5f61e00bf7da790c9df5"],"blockNumber":"0x1008dd2","stateBlockNumber":"latest"}],"id":42,"jsonrpc":"2.0"}", requestMethod="POST", url="https://relay.flashbots.net", code=SERVER_ERROR, version=web/5.4.0)
at Logger.makeError (C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\logger\src.ts\index.ts:213:28)
at Logger.throwError (C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\logger\src.ts\index.ts:225:20)
at C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\web\src.ts\index.ts:251:24
at step (C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\web\lib\index.js:33:23)
at Object.next (C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\web\lib\index.js:14:53)
at fulfilled (C:\Users\Administrator\Desktop\searcher-sponsored-tx-main\node_modules@ethersproject\web\lib\index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)

Not included in block

I keep getting NOT INCLUDED IN BLOCK when using the TransferERC20 method. I set PRIORITY_GAS_PRICE to 3000. I am testing with Goerli and have 0.23ETH in sponsor wallet and trying to send 150DAI from compromised wallet

EIP-1559

hello sir, please update for eip1559 transaction. Thankyou

help

image

please help me what am i missing

Error: cannot estimate gas; transaction may fail or may require manual gas limit

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc":"2.0","id":45,"error":{"code":-32000,"message":"execution reverted"}}","error":{"code":-32000},"requestBody":"{"method":"eth_estimateGas","params":[{"from\

did anyone solve this problem ??

I work on mainnet. This problem does not appear on the goerli and the transaction on the goerli is successfully completed.

This error pops up on Mainnet, interestingly, if the engine is changed to 721approval, it works without any problems even on mainnet, so I have all the variables in the code set well, the problem appears only with TransferERC20. Please help i have a sweeper on my acc and a lot of money in other coins to restore

chainId is needed to run this

I ran the script again but the error occured.
I searched the internet and found tx details should include chainId. I hope you can repair this bug.

BSC

Its work for Binance Chain Network?

Cannot estimate Gas

Hey guys, I am always getting the error: "Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc": "2.0", "id": 45, "error": {"code": -32000, "message": "execution reverted"}}" Its based on the fact that the RPCs cannot estimate gas on accounts with no ether in it. So I am using this script basically because the wallet contains no ether in it, but on the other side i cannot estimate gas with no ether. What should I do?

bsc mainnet

PLs i have my token strucked in BSC token as well pls how can i use the code in terms of BSC to withdraw my token on bsc mainnet

Environment variables aren't being recognized

I put all the environment variables but running npm run start always gives:
Must provide PRIVATE_KEY_EXECUTOR environment variable, corresponding to Ethereum EOA with assets to be transferred
Please help with this

Check simulation Error

(node:781734) UnhandledPromiseRejectionWarning: Error: TX #0 : execution reverted undefined
at Object.checkSimulation (/home/ubuntu/searcher-sponsored-tx/src/utils.ts:23:15)

i got this error while i was trying to recover money from my compromised account, Could you please help with this?

My situation is i have some erc20 tokens in wallet 1 which is compromised with eth sweeper, second wallet with ether to cover transaction fee , 3 rd wallet to receive the tokens , and a 4th wallet just to provide flashbot key , and i changed the token_address in index.ts to the erc20 tokens address, after i followed the steps on readme, i get the above error, and i use infura for eth rpc

Error when using transfererc20

Hello, i deployed this contract on goerli network for testing, it work for approval721, but when i change the engine to trasfererc20, this issue come out, any solution?

revert exception (method="balanceOf(address)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0) at Logger.makeError

Cannot find name 'TransferERC20' while npm install

Hello!

As I want to use for ERC20 token transfer - I uncommented these lines:

const tokenAddress = "0x4da27a545c0c5B758a6BA100e3a049001de870f5"; const engine: Base = new TransferERC20( provider, walletExecutor.address, RECIPIENT, tokenAddress

But when I run npm install it stops with this error:

src/index.ts:82:28 - error TS2304: Cannot find name 'TransferERC20'.

How can I make it work?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.