Skip to content

Commit

Permalink
Merge pull request #100 from Stanback/feature/ethers6
Browse files Browse the repository at this point in the history
Migrate from ethers v5 to v6
  • Loading branch information
epheph authored Feb 5, 2024
2 parents aa5e48e + bd8cbd1 commit aca83ca
Show file tree
Hide file tree
Showing 7 changed files with 1,991 additions and 2,834 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Flashbots-enabled relays and miners expose two new jsonrpc endpoints: `eth_sendB

One key feature this library provides is **payload signing**, a requirement to submit Flashbot bundles to the `mev-relay` service. This library takes care of the signing process via the `authSigner` passed into the constructor. [Read more about relay signatures here](https://github.com/flashbots/mev-relay-js#authentication)

This library is not a fully functional ethers.js implementation, just a simple provider class, designed to interact with an existing [ethers.js v5 installation](https://github.com/ethers-io/ethers.js/).
This library is not a fully functional ethers.js implementation, just a simple provider class, designed to interact with an existing [ethers.js v6 installation](https://github.com/ethers-io/ethers.js/).

## Example

Expand All @@ -20,11 +20,11 @@ npm install --save @flashbots/ethers-provider-bundle
Open up a new TypeScript file (this also works with JavaScript if you prefer)

```ts
import { providers, Wallet } from "ethers";
import { JsonRpcProvider, Wallet } from "ethers";
import { FlashbotsBundleProvider } from "@flashbots/ethers-provider-bundle";

// Standard json rpc provider directly from ethers.js (NOT Flashbots)
const provider = new providers.JsonRpcProvider({ url: ETHEREUM_RPC_URL }, 1)
const provider = new JsonRpcProvider(ETHEREUM_RPC_URL, 1)

// `authSigner` is an Ethereum private key that does NOT store funds and is NOT your bot's primary key.
// This is an identifying key for signing payloads to establish reputation and whitelisting
Expand Down Expand Up @@ -206,8 +206,8 @@ const tx = {
from: wallet.address,
to: wallet.address,
value: "0x42",
gasPrice: BigNumber.from(99).mul(1e9), // 99 gwei
gasLimit: BigNumber.from(21000),
gasPrice: 99n * BigInt(1e9), // 99 gwei
gasLimit: 21000n,
}
const privateTx = {
transaction: tx,
Expand All @@ -226,7 +226,7 @@ const maxBlockNumber = (await provider.getBlockNumber()) + 10;
const minTimestamp = 1645753192;

const res = await flashbotsProvider.sendPrivateTransaction(
privateTx,
privateTx,
{maxBlockNumber, minTimestamp}
)
```
Expand All @@ -238,8 +238,8 @@ To test Flashbots before going to mainnet, you can use the Goerli Flashbots rela
1. Ensure your genericProvider passed in to the FlashbotsBundleProvider constructor is connected to Goerli (gas estimates and nonce requests need to correspond to the correct chain):

```ts
import { providers } from 'ethers'
const provider = providers.getDefaultProvider('goerli')
import { getDefaultProvider } from 'ethers'
const provider = getDefaultProvider('goerli')
```

2. Set the relay endpoint to `https://relay-goerli.flashbots.net/`
Expand Down
Loading

0 comments on commit aca83ca

Please sign in to comment.