flashbots / ethers-provider-flashbots-bundle

Flashbots provider for ethers.js
543 stars 212 forks source link

browser version #61

Open odyslam opened 2 years ago

odyslam commented 2 years ago

Hey everyone,

I have been trying to experiment with a browser-friendly version of this, using tools such as browserify.

Up to this point, I have been unsuccessful. Things I have tried:

I want to make a nice little tool for https://ethtools.odyslam.com

EDIT: After several hours, I manually edited the output bundle.js and managed to make the Flashbots objects available in window. Will update this issue when I have a working PoC. Might be interesting.

odyslam commented 2 years ago

Update: Here is the source file: https://github.com/odyslam/ethtools/blob/feat/flashbots/flashbots.js

This is the addition I needed to make in order to make it work:

if (anyGlobal._FlashbotsBundleProvider == null) {
  anyGlobal._FlashbotsBundleProvider = FlashbotsBundleProvider;
  anyGlobal._FlashbotsBundleResolution = FlashbotsBundleResolution;
}

The file is the result of compiling the typescript library and then using browserify --standalone.