function calculate(
   uint index
       )public view returns(uint, uint, bool){
   uint avh1;
   uint avh2;
   uint avh3;
   uint avl1;
   uint avl2;
   uint avl3;
   uint allowbuy;
   uint allowsell;
           //function add(uint256 a, uint256 b) internal pure returns (uint256) {
        //   return a + b;
           priceHistory memory coinToReturn = stableCoins[index];
           avh1 = coinToReturn.highestPricethismonth.add (coinToReturn.highestPrice2MonthsAgo);
           avh2 = coinToReturn.highestPrice3MonthsAgo.add (coinToReturn.highestPrice4MonthsAgo);
           avh3 = avh1.add (avh2); avh3/4= allowsell;
           avl1 = coinToReturn.lowestPricethismonth.add (coinToReturn.lowestPrice2MonthsAgo);
           avl2 = coinToReturn.lowestPrice3MonthsAgo.add (coinToReturn.lowestPrice4MonthsAgo);
           avl3 = avl1.add (avl2); avl3.div  (4)  = allowbuy;
          return (allowbuy);
          return (allowsell);
          return (success);

on the lines where I end up dividing, no matter the methods i use to divide I keep getting the same error message, "expression has to be an 1value"


1 Answer 1


These are not valid solidity code

avh3/4= allowsell;


avl3.div  (4)  = allowbuy;

To assign the result to the varibales you have to swap left and right

allowsell = avh3/4;


allowbuy = avl3.div(4);

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.