6

I'm attempting to use the function send() in Solidity I've got this error when i try to compile my contract with truffle :

Warning: Return value of low-level calls not used.

any idea about it?

thank you

  • Abdelalah try to share your code or a snippet in order to figure out the problem. – Badr Bellaj Oct 12 '16 at 11:27
  • just check for the return value of the function call. it will return 0 or 1depending upon the failure or success of the function call. – anand011090 Mar 22 '18 at 10:14
5

you could use a modifier :

modifier send_it(uint _amount, address _address ) {
    if (msg.value < _amount)
        throw;
    _
    if (msg.value > _amount)
        _address .send(_amount - msg.value);
}

  function x(address _newOwner)
        send_it(200 ether,msg.sender) //exemple
    {

     }

or you could just use simple checking (throw if send failed for some reason):

if (_address.send())
 throw;
7

It is because your code is not checking the return status from the send(...) function:

Using this code below in Solidity Online:

pragma solidity ^0.4.0;

contract Test {
    function testit(address a) {
        a.send(123);
    }
}

I get the the following warning message: Warning: Return value of low-level calls not used..

Using the code below instead will remove the warning:

pragma solidity ^0.4.0;

contract Test {
    function testit(address a) {
        if (!a.send(123))
            throw;
    }
}

The compiler is warning you to check the return status of the send(...) function. Solution - check the return status. This is one of the recommendations on smart contract best practices after the USD 50 million The DAO hack.

Further reference - Ethereum Contract Security Techniques and Tips.

0

In solidity version 0.5.0 they have made breaking changes and returns bool and bytes. Reference is here.

So you have to use:

(bool success, bytes memory data) = otherContract.send("f")

to get the return values and then use it accordingly.

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.