[Ethereum]
.transfer(amount) not working

soliditytransactions

I want to send some eth from within a contract to an address. According to the docs there are two possibilities:

address.transfer(uint256 amount):
send given amount of Wei to Address, throws on failure

and

address.send(uint256 amount) returns (bool):
send given amount of Wei to Address, returns false on failure

It seems easier to use .transfer, as this will automaticall throw an exception and revert any change performed within the transaction. But the compiler says the method is not available:

Error: Member "transfer" not found or not visible after argument-dependent lookup in address

I have a feeling I'm missing something obvious, but can't figure it out, probably related to the "argument-dependent lookup". Any ideas?

Best Answer

transfer was introduced in Solidity 0.4.10:

Introduce .transfer(value) for sending Ether.

Please check the version of Solidity you are using.

Related Topic