This is my first contract ever (building on an own example learning case I made up).
Given this Contract (simplified):
unit gEval = 0;
contract Group {
struct Grp {
string name;
uint orgId;
Contrib[] contribs;
}
struct Contrib {
uint id;
uint grpId;
Evals[] evals;
}
struct Eval {
uint id;
address evaluator;
uint result;
}
function evalContrib(Contrib c, uint res) public {
require(msg.sender != c.contributor);
Eval eval = Eval(gEval++,msg.sender, res);
c.evals.push(eval);
}
}
I get :
Error: Member "push" is not available in struct Group.Eval memory[] memory outside of storage. c.evals.push(eval); ^----------------^
This is what I understand: The Contrib c
param in the evalContrib
function is a memory parameter, as it is a function parameter, while I am trying to call c.evals.push(eval)
which would be storage
I guess.
I tried several combinations of assigning storage
or memory
pointer but I haven't been able to solve this.
How can I implement something like that? Can I only get a reference by Id maybe, e.g. contribs[id].evals.push(eval)
?
Note: My design may be utterly inefficient for solidity (lots of structs with arrays), so I am happy for any suggestion.