3

Noticed this wierd contract someone keeps creating, looks like some sort of scam, how does it work?

https://etherscan.io/address/0x4fa738cf30036505d106b22f60e64bf52e64aa77/advanced#code:

/**
 *Submitted for verification at Etherscan.io on 2020-08-16
*/

contract a1_quiz
{
    function Try(string _response) external payable 
    {
        require(msg.sender == tx.origin);

        if(responseHash == keccak256(_response) && msg.value > 1 ether)
        {
            msg.sender.transfer(this.balance);
        }
    }

    string public question;

    bytes32 responseHash;

    mapping (bytes32=>bool) admin;

    function Start(string _question, string _response) public payable isAdmin{
        if(responseHash==0x0){
            responseHash = keccak256(_response);
            question = _question;
        }
    }

    function Stop() public payable isAdmin {
        msg.sender.transfer(this.balance);
    }

    function New(string _question, bytes32 _responseHash) public payable isAdmin {
        question = _question;
        responseHash = _responseHash;
    }

    constructor(bytes32[] admins) public{
        for(uint256 i=0; i< admins.length; i++){
            admin[admins[i]] = true;        
        }       
    }

    modifier isAdmin(){
        require(admin[keccak256(msg.sender)]);
        _;
    }

    function() public payable{}
}
2

If you only read the contract regular transaction history you would assume that after creation it was initialized by calling Start(string _question, string _response) at transaction 0xc96ddea6... block 10668934 with

  • _question = "What kind of clothes do lawyers wear?"
  • _response = " LawsuiT "

But if you see the internal transactions there was a previous call to function New(string _question, bytes32 _responseHash) in transaction 0xbed05f75... at block 10668933.

The call to Start did not change responseHash as a victim would have expected, so the call to Try will fail.

Note: Don't play with these "honey pots", it is very easy to lose and unlikely you will win.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.