4

Using the online Solidity compiler I get this error:

browser/TokenSales.sol:18:10: Error: Member "value" not found or not visible after argument-dependent lookup in function (address) external returns (bool) - did you forget the "payable" modifier?
    if (!TokenSalesInterface(tokenSales).proxyPurchase.value(msg.value).gas(106000)(payout)) throw;
         ^-------------------------------------------------^

For this code:

contract ProxyPayment {

  address payout;
  address tokenSales; 
  address owner;

  function ProxyPayment(address _payout, address _tokenSales) {
    payout = _payout;
    tokenSales = _tokenSales;
    owner = _payout;
  }

  function () {
    if (!TokenSalesInterface(tokenSales).proxyPurchase.value(msg.value).gas(106000)(payout)) throw;
  }

}

This is my repo.

How can I fix this issue?

2

You can fix it by whether downgrading the used compiler to a version prior to 0.4.0 or using the following call :

 if (!TokenSalesInterface(tokenSales).call.gas(106000).value(msg.value)(bytes4(sha3("proxyPurchase(address)")),payout)) {
             throw;
         }

if you are using a recent compiler don't forget to use payable in the functions which receive ethers. related post : How to specify gas/value when making a call using abstract contracts?

  • Why should you downgrade the compiler version. The code should be modified to match the latest once since not many changes would be required and great features are provides(especially after 0.4.0=9) – aviral agrawal Aug 24 '17 at 9:31
1
+50

You are trying to access msg.value in

function () {
  if (!TokenSalesInterface(tokenSales).proxyPurchase.value(msg.value).gas(106000)(payout)) throw;
}

but the fallback function is not defined as payable, so it cannot take ether.

Also the function

function proxyPurchase(address _user) returns (bool success) {
  return purchase(_user, msg.value);
}

Takes address as an input and returns boolean value while you are passing uint value as msg.value.

0

You could try something like this:

  function () payable { 
    if (!TokenSalesInterface(tokenSales).proxyPurchase(msg.sender)) throw;
  }

The function proxyPurchase requires one argument:

  function proxyPurchase(address _user) returns (bool success) {
    return purchase(_user, msg.value);
  }

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.