1
pragma solidity 0.5.16;

contract receive{
function dep() external payable{
    //Processing the received ether
    }
}
function fallback() external payable{}

pragma solidity 0.5.16;

import "./receive.sol";

contract send {
    receive rc = receive (address(0x0DCd2F752394c41875e259e00bb44fd505297caF)); //Address of deployed receive contract
    function snd(uint256 amount) public payable {
        rc.dep.transfer(amount);
    }
    function fallback() external payable{}
}

I get the following error on send.sol:8:9 while compiling on remix.

TypeError: Member "transfer" not found or not visible after argument dependant lookup in function () payable external.
rc.dep.transfer(amount);
^----------------------^

I do not know how to convert address of rc to address payable. I also tried rc.dep.value(amount)() but it sends only data not wei as I want to. Any help would be much appreciated!

1
0

The correct syntax is

function snd(uint256 amount) public payable {
    rc.dep.value(amount)();
}
8
  • I forgot to mention that I tried this too. This call was only able to send data not wei
    – hari.1296
    Mar 13 '20 at 13:15
  • Did the transaction revert? Did the contract have enough ether to send? Amount should be in weis, what value did you use?
    – Ismael
    Mar 13 '20 at 14:05
  • @hari.1296 I run your contract with my fix in remix and it works as expected. Instead of using amount you probably want to use msg.value.
    – Ismael
    Mar 13 '20 at 14:21
  • I sent "1000000000000000000" as a string. How should I specify that it is wei?
    – hari.1296
    Mar 13 '20 at 14:59
  • @hari.1296 That is 1 ether (web3 has two functions fromWei, toWei to make the conversion). Did the contract have enough balance? Did you send some ether when call snd? The ether has to be in the contract.
    – Ismael
    Mar 13 '20 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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