I am currently taking a course in Solidity and we get presented with weekly challenges that we should try to solve. This time the general topic is SafeMath and the challenge looks the following:
contract HopAndMaltOracle{
// Contract oracle
address public oracle;
modifier onlyOracle(){
require(msg.sender == oracle);
_;
}
uint public maltMarketCap;
uint public hopMarketCap;
// Callback function
event MaltMarketCapChanged();
event HopMarketCapChanged();
constructor(uint _maltCap, uint _hopCap) public payable {
oracle = msg.sender;
maltMarketCap = _maltCap;
hopMarketCap = _hopCap;
emit MaltMarketCapChanged();
emit HopMarketCapChanged();
}
function updateMaltMarketCap(uint _cap) public onlyOracle {
maltMarketCap = _cap;
emit MaltMarketCapChanged();
}
function updateHopMarketCap(uint _cap) public onlyOracle {
hopMarketCap = _cap;
emit HopMarketCapChanged();
}
function IDidIt() public{
require(address(this).balance % 2 == 1);
msg.sender.transfer(address(this).balance);
}
}
The goal is to reduce the balance of the contract to 0 (by somehow calling IDidIt()). Now looking at the contract it seems to me like none of the methods can be invoked since all of them are either using the onlyOracle modifier or are the constructor (except for IDidIt() ).
My idea would be to send Ether to the contract in order to increase the balance to something that would satisfy
require(address(this).balance % 2 == 1);
but I can't find a way to do so since the fallback function is not acceppting my payments (tried with:
eth.sendTransaction({from:myAddress,to:contractAddress,value:1});
The starting balance of the contract is 2 Ether. I am not asking for a solution, but a nudge in the right direction would definitely help :)
IDidIt
.