https://github.com/bereket-g/etherume-front-run-attack
https://github.com/bereket-g/etherume-front-run-attack
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bereket-g/etherume-front-run-attack
- Owner: Bereket-G
- Created: 2023-01-31T19:31:00.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T19:31:28.000Z (over 2 years ago)
- Last Synced: 2025-01-22T20:30:56.330Z (4 months ago)
- Language: TypeScript
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Demo Front Running Attack
Transactions take some time before they are mined. An attacker can watch the transaction pool and send a transaction, have it included in a block before the original transaction. This mechanism can be abused to re-order transactions to the attacker's advantage.
A contract `FrontRun.sol` rewards who ever comes up with the keyword behind the hash.
Neverthless if a user comes up with the right keyword the front-run bots won't let him take the prize.
They will re-broadcast the transaction with higher gas then their transactions will take precedence.1st Terminal: Deploy contract to Goerli network.
```shell
npx hardhat run --network goerli ./scripts/deploy.ts
```2nd Terminal: Start the front-running bot
```shell
npx hardhat run --network goerli ./scripts/front-run-script.ts
```3rd Terminal: User trying to claim reward with a right answer
```shell
npx hardhat run --network goerli ./scripts/callSolve.ts
```