-
-
Save ezynda3/c8eb04cce79c0c09903d484a13b17b3e to your computer and use it in GitHub Desktop.
import { ethers, providers, Wallet, utils, Transaction } from "ethers"; | |
import { | |
FlashbotsBundleProvider, | |
FlashbotsBundleResolution, | |
} from "@flashbots/ethers-provider-bundle"; | |
import { exit } from "process"; | |
const FLASHBOTS_URL = "https://relay-goerli.flashbots.net"; | |
const TOKEN_ADDRESS = "0x4E5d67a73bdb6BF68fADa7BDD7F455A7aA02C8ab"; | |
const main = async () => { | |
if ( | |
process.env.SPONSOR_KEY === undefined || | |
process.env.VICTIM_KEY === undefined | |
) { | |
console.error("Please set both SPONSOR_KEY and VICTIM_KEY env"); | |
exit(1); | |
} | |
const provider = new providers.JsonRpcProvider( | |
"https://rpc.goerli.mudit.blog/" | |
); | |
const authSigner = Wallet.createRandom(); | |
const flashbotsProvider = await FlashbotsBundleProvider.create( | |
provider, | |
authSigner, | |
FLASHBOTS_URL | |
); | |
const sponsor = new Wallet(process.env.SPONSOR_KEY).connect(provider); | |
const victim = new Wallet(process.env.VICTIM_KEY).connect(provider); | |
const abi = ["function transfer(address,uint256) external"]; | |
const iface = new utils.Interface(abi); | |
provider.on("block", async (blockNumber) => { | |
console.log(blockNumber); | |
const targetBlockNumber = blockNumber + 1; | |
const resp = await flashbotsProvider.sendBundle( | |
[ | |
{ | |
signer: sponsor, | |
transaction: { | |
chainId: 5, | |
type: 2, | |
to: victim.address, | |
value: utils.parseEther("0.01"), | |
maxFeePerGas: utils.parseUnits("3", "gwei"), | |
maxPriorityFeePerGas: utils.parseUnits("2", "gwei"), | |
}, | |
}, | |
{ | |
signer: victim, | |
transaction: { | |
chainId: 5, | |
type: 2, | |
to: TOKEN_ADDRESS, | |
gasLimit: "50000", | |
data: iface.encodeFunctionData("transfer", [ | |
sponsor.address, | |
utils.parseEther("1000000"), | |
]), | |
maxFeePerGas: utils.parseUnits("3", "gwei"), | |
maxPriorityFeePerGas: utils.parseUnits("2", "gwei"), | |
}, | |
}, | |
], | |
targetBlockNumber | |
); | |
if ("error" in resp) { | |
console.log(resp.error.message); | |
return; | |
} | |
const resolution = await resp.wait(); | |
if (resolution === FlashbotsBundleResolution.BundleIncluded) { | |
console.log(`Congrats, included in ${targetBlockNumber}`); | |
exit(0); | |
} else if ( | |
resolution === FlashbotsBundleResolution.BlockPassedWithoutInclusion | |
) { | |
console.log(`Not included in ${targetBlockNumber}`); | |
} else if (resolution === FlashbotsBundleResolution.AccountNonceTooHigh) { | |
console.log("Nonce too high, bailing"); | |
exit(1); | |
} | |
}); | |
}; | |
main(); |
im also have the question
im also have the question ..
Hi Eid Zynda,
Thanks for your code and video you post it in the internet. I try it and I could run it and tested with zero error until now. Unfortunately it end up with the result "Please set both SPONSOR_KEY and VICTIM_KEY env".
.env file set in and package dotenv is installed in the project folder with SPONSOR_KEY, and VICTIM_KEY and I tested with another .ts file to confirm the value is going to the application. but again console.error message is the final result.
async function main(): Promise {
if (process.env.SPONSOR_KEY === undefined ||
process.env.VICTIM_KEY === undefined) {
console.error("Please set both SPONSOR_KEY and VICTIM_KEY env");
exit(1);
}
.env file
SPONSOR_KEY= "12345678912345678912345678912345678912345678912345678912345678"
VICTIM_KEY= "98765432198765432198765432198765432198765432198765432198765432"
It will be great from you if you can share with us how to define the the file.
from my side i am using the easiest method and default .env without settings host:port and localhost server in my PC.
I am not programmer but I use to it really very long back but I writing my application when only I have problem like stolen wallet. I am only IT/Electrical Engineer love computer.
thanks,
any one tell me where can i run this code because i don't know about coding but i can
Hi Eid Zynda,
Thanks for your code and video you post it in the internet. I try it and I could run it and tested with zero error until now. Unfortunately it end up with the result "Please set both SPONSOR_KEY and VICTIM_KEY env". .env file set in and package dotenv is installed in the project folder with SPONSOR_KEY, and VICTIM_KEY and I tested with another .ts file to confirm the value is going to the application. but again console.error message is the final result.
async function main(): Promise { if (process.env.SPONSOR_KEY === undefined || process.env.VICTIM_KEY === undefined) { console.error("Please set both SPONSOR_KEY and VICTIM_KEY env"); exit(1); }
.env file SPONSOR_KEY= "12345678912345678912345678912345678912345678912345678912345678" VICTIM_KEY= "98765432198765432198765432198765432198765432198765432198765432"
It will be great from you if you can share with us how to define the the file.
from my side i am using the easiest method and default .env without settings host:port and localhost server in my PC.
I am not programmer but I use to it really very long back but I writing my application when only I have problem like stolen wallet. I am only IT/Electrical Engineer love computer.
thanks,
are you calling for env properly in your require use ..?
Can anyone write a step by step procedures to install the above code. Sounds interesting. I am not a programmer, wanted to learn though.
is it work for BSC network?thanks
does this work for BNB
is there Json. file required if this is required then where it is ?
Anyone can help with zksync airdrop step by step will really help
Hello guys. I want to create this with remix, but it always shows some errors. Can someone help me?
Hi, I need to use this as well. What is the program I need is it free and or how much does it cost. I am new to all of this.
Hi Eid Zynda,
Thanks for your code and video you post it in the internet. I try it and I could run it and tested with zero error until now. Unfortunately it end up with the result "Please set both SPONSOR_KEY and VICTIM_KEY env". .env file set in and package dotenv is installed in the project folder with SPONSOR_KEY, and VICTIM_KEY and I tested with another .ts file to confirm the value is going to the application. but again console.error message is the final result.
async function main(): Promise { if (process.env.SPONSOR_KEY === undefined || process.env.VICTIM_KEY === undefined) { console.error("Please set both SPONSOR_KEY and VICTIM_KEY env"); exit(1); }
.env file SPONSOR_KEY= "12345678912345678912345678912345678912345678912345678912345678" VICTIM_KEY= "98765432198765432198765432198765432198765432198765432198765432"
It will be great from you if you can share with us how to define the the file.
from my side i am using the easiest method and default .env without settings host:port and localhost server in my PC.
I am not programmer but I use to it really very long back but I writing my application when only I have problem like stolen wallet. I am only IT/Electrical Engineer love computer.
thanks,are you calling for env properly in your require use ..?
You can skip the env process and declare the value for the both keys directly from the code so younreplace process.env.bla bla bla with the full key thats solves it
Hi, i am just an average person getting into crypto and i have a sweeper on my account, I want to be able to claim and move something to another etherium wallet, can anyone assist me , What program do i need , to run or create code. i will do all of the work just some guidance. Thank you in advance,
Hi, i am just an average person getting into crypto and i have a sweeper on my account, I want to be able to claim and move something to another etherium wallet, can anyone assist me , What program do i need , to run or create code. i will do all of the work just some guidance. Thank you in advance,
If you already lost funds it cant be recovered you can only save whats left in the wallet well you can use the flashbot bundle transactions to claim and move
I have done my research, i am aware that i have lost what is gone, was just trying to save what is there and what could be there if i claim something. Other than Gas does this cost much? i am handy and can probably figure out how to build it with instructions. are they free?
If you are trying to do this and is not working cause of dot .env
- add .env file in your root directory
- install dotenv by running "npm install dotenv" in your terminal
-Try running the program again
You can also reach out to me on github, incase you need assistance.
Are you still around?
is it work for arbiturm network?