1

When I run these two contracts, I first deploy habibconcert and then changer. When I call displayTickets_numbers, the IDE crashes.

enter image description here

enter image description here

Here is the contract source code:

pragma solidity ^0.4.0;

contract changer{


       habibconcert firstObject =    habibconcert(0x692a70d2e424a56d2c6c27aa97d1a86395877b3a);

       interfacer public changers;

      function changeTickets(uint new_tickets)  {


       //   changers = interfacer();      

          changers.changeTickets_numberTicket(new_tickets);

        //  firstObject.tickets = new_tickets;
        //   uint updateTickets =  firstObject.tickets  = firstObject.tickets + new_tickets;
        //   return ( updateTickets);
  }


    function displayTickets_numbers()constant returns(uint){

               return displayTickets_numbers();
    }


    }




interface interfacer{


    function changeTickets_numberTicket(uint new_tickets);

    function displayTickets_numbers() constant returns(uint);


}




contract habibconcert{

      uint  public tickets = 6;

      address owner_of_tickets;

      uint constant price = 1 ether;

       mapping(address=>uint) public purchasers;

      function habibconcert()payable{

            owner_of_tickets =  msg.sender;
      }


                function  displayTickets_numbers()constant returns(uint){

                    return tickets;


                }






              function changeTickets_numberTicket (uint newtickets) {

                         tickets +=newtickets;

                   }











        modifier ownLycreature(){


            require(msg.sender ==  owner_of_tickets) ;

            //   && tickets == 0
            _;

            }



               function changeTickets_number (uint newtickets) ownLycreature{

                         tickets +=newtickets;

                   }




    function buytickets(uint amount)payable{

          if(msg.value!=(amount*price) || amount>tickets){

              throw;
          }

          purchasers[msg.sender] +=amount;

          tickets -=amount;


        // if(tickets == 0){

        //     //selfdestruct(owner_of_tickets);

        // }


    }        





}
  • I guess this should be filed as issue in remix github – Davide C Apr 1 '18 at 9:20
2

because you have this

function displayTickets_numbers()constant returns(uint){

           return displayTickets_numbers();
}

an infinite recursive call !!!

it will work if you write instead :

   habibconcert  in_h=new habibconcert();
    function displayTickets_numbers_()constant returns(uint){

               return in_h.displayTickets_numbers();
    }
  • don't forget to accept the answer if it solves you problem – Badr Bellaj Apr 10 '18 at 8:08

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.