MultiversX Tracker is Live!

Flashbots help

Etherum Reddit

More / Etherum Reddit 169 Views

I'm trying to figure out how to use flashbots. To understand flashbot I'm trying to call the `Seaport` contract's `name` method with the following code.

import { providers, Wallet } from "ethers"; import { FlashbotsBundleProvider, FlashbotsBundleResolution, } from "@flashbots/ethers-provider-bundle"; import { readFile } from 'fs/promises'; let ABI = JSON.parse( await readFile( new URL('./seaport_abi.json', import.meta.url) )) ABI = JSON.parse(ABI.result) //seaport contract's ABIs fetched from etherscan const GWEI = 10n ** 9n; const ETHER = 10n ** 18n; const CHAIN_ID = 1; // goerli const FLASHBOTS_ENDPOINT = "https://rpc.flashbots.net/fast"; const provider = new providers.JsonRpcProvider({ // @ts-ignore url: "https://mainnet.infura.io/v3/INFURA_API_KEY", }); // @ts-ignore // const wallet = new Wallet(process.env.PRIVATE_KEY, provider); const signer = new Wallet( "0x2000000000000000000000000000000000000000000000000000000000000000" ); // const signer = Wallet.createRandom(); const flashbot = await FlashbotsBundleProvider.create( provider, signer, FLASHBOTS_ENDPOINT ); const wallet = new Wallet("MY_WALLET_PRIVATE_KEY", provider); provider.on("block", async (block) => { console.log(`block: ${block}`); const signedTx = await flashbot.signBundle([ { signer: wallet, transaction: { chainId: CHAIN_ID, // EIP 1559 transaction type: 2, value: 0, data: "0x", maxFeePerGas: GWEI * 3n, maxPriorityFeePerGas: GWEI * 2n, gasLimit: 1000000, to: "0x00000000006c3852cbEf3e08E8dF289169EdE581", }, }, ]); const targetBlock = block + 1; const sim = await flashbot.simulate(signedTx, targetBlock); if ("error" in sim) { console.log(`simulation error: ${sim.error.message}`); } else { // console.log(`simulation success: ${JSON.stringify(sim, null, 2)}`); console.log(`simulation success`); } }) 

And I'm getting the following error:

simulation error: rpc method is not whitelisted 

Can anyone guide me on what I'm doing wrong?

submitted by /u/shoaib_atiq1
[link] [comments]
Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments