Answer the question
In order to leave comments, you need to log in
How to transfer ether from address to address in Solidity?
The question is this: in the Remix development environment, I have 5 virtual accounts (100 ethers each). I want to transfer 10 ethers from the 1st account to the 2nd one. Without notifications, without intermediate wallets, not abstract "values" of some kind of map, which is a type of currency, namely ethers.
Here is the code (not working). I just wanted to enter the address of the second one + 10 ethers while standing on the first account and for the transfer to take place, which I saw when I changed the account.
pragma solidity >0.4.22 <0.6.0;
contract Test {
function pay(address _user, uint _value) payable public {
_user.transfer(_value);
}
}
Answer the question
In order to leave comments, you need to log in
Since some version (can't remember exactly which one), transfer only works with address payable .
Try this option:
function pay(address payable _user, uint _value) payable public {
_user.transfer(_value);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question