1

I can get the AddPerson() work on the actual private ethereum network. But when I call AddPerson() on testrpc, it gives me :

"callback contain no result Error: VM Exception while processing transaction: invalid opcode" message.

I use the remix browser compiler to compile and deploy.

I checked the gas etc. etc. but it just does not work on testrpc.

Any help will be appreciated

pragma solidity ^0.4.15;


library MyLib {


    struct Person {
       uint balance ;
    } 

    struct PersonsData {
      mapping(address => Person)  person   ;
      uint numpersons                      ; 
    }


    function MyLibInit(PersonsData storage self)  { 
       self.numpersons = 0 ; 
    }


    function AddPerson(PersonsData storage self)  public {
        Person  memory p ;

        p.balance = 0 ; 
        self.person[msg.sender]  =  p; 
        self.numpersons++ ; 

    }
}


contract PersonContract {

    using MyLib for MyLib.PersonsData ;

    MyLib.PersonsData mypersons  ;

    function PersonContract() payable { 
        mypersons.MyLibInit() ;
    }

    function () {
        revert() ; 
    }

    function AddPerson()  payable public {
        mypersons.AddPerson() ; 
    }

}
  • I just copied your code and ran it...worked fine for me – thefett Aug 18 '17 at 20:45
  • When did you download your version of testrpc ? – user813 Aug 19 '17 at 12:14
  • I was using remix, are you talking about trying to run it in truffle or via web3? – thefett Aug 20 '17 at 0:43
  • No, I mean testrpc. I am also connecting to testrpc from remix. I tried both Firefox/Chrome. Same problem. I downloaded/installed testrpc just before i did these tests. Since yours was working, I was wondering whether it may be related to the version of testrpc. – user813 Aug 20 '17 at 8:53

Your Answer

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

Browse other questions tagged or ask your own question.