I need to transfer ether from msg.sender to an address in solidity.How should i do it

2 Answers 2


First make payable function in you contract, and check amount of ether that was transferred by user to your contract:

require(msg.value == 1 ether, 'Wrong ether value transferred');

next you can transfer corresponding amount to destination address:

address(_dst).send(1 ether);

or in one function:


Note that you should use call instead of transfer or send. More on that here: https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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