I have a parent contract:

contract Transaction {

enum C_facts {

C_facts public c_fact = C_facts.Inital;
function nextCFact(bool happyFlow) internal {
    if(happyFlow == true){
        c_fact = C_facts(uint(c_fact) + 1);
    if(happyFlow == false && c_fact == C_facts.Requested){
        c_fact = C_facts.Declined;
    if(happyFlow == false && c_fact == C_facts.Declared){
        c_fact = C_facts.Rejected;
modifier transitionNext(bool happyFlow)

Then I have a child contract:

contract RentalCompleting is Transaction{
function promiseRentalCompleting() public
         returns (address){
             DepositPaying depositPaying = new DepositPaying(address(this));
             return address(depositPaying);

And I want to change the c_fact of RentalCompleting at DepositPaying contract:

contract DepositPaying is Transaction {
        RentalCompleting rentalCompleting;
        constructor(address _rentalCompleting) public{
           rentalCompleting = RentalCompleting(_rentalCompleting);}
        function acceptDepositPaying() public
         returns (address)
             require(da_invoiceAmount == pm_invoiceAmount);
             rentalCompleting.c_fact() = C_facts(uint(c_fact) + 1);    <=ERROR HERE=>
             return address(rentalCompleting);

But i'm getting TypeError: Expression has to be an lvalue. on the line marked by:<=ERROR HERE=>. Does anyone know how to fix this?

  • This is not Java dude! You cannot set a variable of another contract by passing a reference of it in the left hand side of an assignment expression. You need to implement a setter function in the contract where that variable is located, and then call that setter function from the contract where you want to set this variable. – goodvibration Aug 4 at 12:26
  • oh i see thanks – martasaparicio Aug 4 at 12:27
  • Depending on your system requirement, you might also need to restrict calling permission on that setter function. – goodvibration Aug 4 at 12:27
  • yup i will need that – martasaparicio Aug 4 at 12:28
  • how could i restrict calling permission on that setter function? i did function setCFact(C_facts _c_fact) public { c_fact = _c_fact; } but i don't want to let the user to have access to this function... i changed to internal and private but i get a compilation error @goodvibration – martasaparicio Aug 4 at 12: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.