Code is:
pragma solidity ^0.4.16;
contract init {
address owner;
function init()
{
owner = msg.sender;
}
function send() public payable{
owner.transfer(msg.value);
}
}
Code is:
pragma solidity ^0.4.16;
contract init {
address owner;
function init()
{
owner = msg.sender;
}
function send() public payable{
owner.transfer(msg.value);
}
}
Taking a better look at the screenshot you provided, you are not sending any value in your transaction, therefore nothing happens...
You need to make sure to set the value
option when initiating the send
transaction.
If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value
with address(this).balance
.
If the balance of the contract prior to calling function send
is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.
Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send
has just transferred to the contract.