I am following the tutorial at https://medium.com/@gus_tavo_guim/reentrancy-attack-on-smart-contracts-how-to-identify-the-exploitable-and-an-example-of-an-attack-4470a2d8dfe4 and deploying the following contract:
pragma solidity ^0.4.16;
contract HoneyPot {
mapping (address => uint) public balances;
function HoneyPot() payable {
put();
}
function put() payable {
balances[msg.sender] = msg.value;
}
function get() {
if (!msg.sender.call.value(balances[msg.sender])()) {
revert();
}
balances[msg.sender] = 0;
}
function() {
revert();
}
}
When this contract receives ether, the HoneyPot()
constructor should be executed, which will call the put()
function and run the balances[msg.sender] = msg.value;
line. However, when I send ether to this contract I get a "bad instruction" error on etherscan (after waiting a couple of minutes and using the ropsten test network). What might the issue be here? as both HoneyPot()
and put()
functions are payable (as is required when receiving ether).