flashbotsfailedtx

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 5 Imported by: 0

README

Flashbots failed transactions

Iterate over Ethereum blocks to get failed Flashbots transactions.

Uses https://github.com/metachris/go-ethutils

Notes:

  • You can set the geth node URI as environment variable ETH_NODE, or pass it in as -eth argument.
  • You should use an IPC connection to the geth node, as there are a lot of API calls (one for each tx).
# Subscribe to new blocks and find failed Flashbots tx:
go run cmd/flashbots-failed-tx/main.go -watch
go run cmd/flashbots-failed-tx/main.go -watch -silent  # print only failed transactions

# Historic, using a starting block
go run cmd/flashbots-failed-tx/main.go -block 12539827           # 1 block
go run cmd/flashbots-failed-tx/main.go -block 12590513
go run cmd/flashbots-failed-tx/main.go -block 12539827 -len 5    # 5 blocks
go run cmd/flashbots-failed-tx/main.go -block 12539827 -len 10m  # all blocks within 10 minutes of given block
go run cmd/flashbots-failed-tx/main.go -block 12539827 -len 1h   # all blocks within 1 hour of given block
go run cmd/flashbots-failed-tx/main.go -block 12539827 -len 1d   # all blocks within 1 day of given block
go run cmd/flashbots-failed-tx/main.go -block 12539827 -len 1d -silent  # don't print information for every block

# Historic, using a starting date
go run cmd/flashbots-failed-tx/main.go -date -1d -len 1h         # all blocks within 1 hour of yesterday 00:00:00 (UTC)
go run cmd/flashbots-failed-tx/main.go -date 2021-05-31 -len 1d  # all blocks from this day (00:00:00 -> 23:59:59 UTC)
go run cmd/flashbots-failed-tx/main.go -date 2021-05-31 -hour 3 -min 53 -len 5m  # all blocks within 1 hour of given date and time (UTC)

You can also install this tool as flashbots-failed-tx binary:

go install github.com/metachris/flashbots-failed-tx/cmd/flashbots-failed-tx@master
flashbots-failed-tx -h

Screenshot

Interesting blocks:

  • 12539827 - 1 failed 0-gas tx
  • 12590513 - ~100 failed 0-gas tx
  • 12527162 - failed Flashbots tx

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFlashbotsApiDoesntHaveThatBlockYet = errors.New("flashbots API latest height < requested block height")
)

Functions

This section is empty.

Types

type BlockWithFailedTx added in v0.2.1

type BlockWithFailedTx struct {
	BlockHeight int64
	FailedTx    []FailedTx
}

BlockWithFailedTx is used by the webserver, which returns the last 100 blocks with failed tx

type FailedTx

type FailedTx struct {
	Hash        string
	From        string
	To          string
	Block       uint64
	IsFlashbots bool // if false then it's a failed 0-gas tx but not from Flashbots
}

FailedTx contains information about a failed 0-gas or Flashbots tx

type FlashbotsApiBlock

type FlashbotsApiBlock struct {
	BlockNumber       int64  `json:"block_number"`
	Miner             string `json:"miner"`
	MinerReward       string `json:"miner_reward"`
	CoinbaseTransfers string `json:"coinbase_transfers"`

	GasUsed      int64                     `json:"gas_used"`
	GasPrice     string                    `json:"gas_price"`
	Transactions []FlashbotsApiTransaction `json:"transactions"`
}

type FlashbotsApiTransaction

type FlashbotsApiTransaction struct {
	Hash             string `json:"transaction_hash"`
	TxIndex          int64  `json:"tx_index"`
	BundleIndex      int64  `json:"bundle_index"`
	BlockNumber      int64  `json:"block_number"`
	EoaAddress       string `json:"eoa_address"`
	ToAddress        string `json:"to_address"`
	GasUsed          int64  `json:"gas_used"`
	GasPrice         string `json:"gas_price"`
	CoinbaseTransfer string `json:"coinbase_transfer"`
	TotalMinerReward string `json:"total_miner_reward"`
}

type FlashbotsBlockApiResponse

type FlashbotsBlockApiResponse struct {
	LatestBlockNumber int64               `json:"latest_block_number"`
	Blocks            []FlashbotsApiBlock `json:"blocks"`
}

func GetFlashbotsBlock

func GetFlashbotsBlock(blockNumber int64) (response FlashbotsBlockApiResponse, err error)

https://blocks.flashbots.net/v1/blocks

func IsFlashbotsTx

func IsFlashbotsTx(block *types.Block, tx *types.Transaction) (isFlashbotsTx bool, response FlashbotsBlockApiResponse, err error)

func (*FlashbotsBlockApiResponse) GetTxMap

func (*FlashbotsBlockApiResponse) IsFlashbotsTx added in v0.2.0

func (r *FlashbotsBlockApiResponse) IsFlashbotsTx(hash string) bool

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL