tfontain
tfontain

Reputation: 56

Transfer the gas value of contract to my own address

What happens ?

    msg.sender.transfer(msg.value);

remix.eth is just telling me

errored: Cannot read property 'op' of undefined

Upvotes: 0

Views: 263

Answers (1)

James Lockhart
James Lockhart

Reputation: 1040

Works fine for me:

pragma solidity ^0.4.0;

contract Test {

    function () payable {
        msg.sender.transfer(msg.value);
    }

}

I get invalid opcode if I don't specify the function is payable.

Upvotes: 1

Related Questions