This is my data structure for storing a list of questions which will be different for every address
struct Question{
uint16 id;
string question_string;
string answer;
}
and this is stored as an array being the value of the mapping while address of the user being the key
mapping(address=>Question[]) public user_questions;
Now I want to update a particular question's answer for a user. What can I do for the same?
I tried using the following function:
function addAnswer(address _user, uint16 _id, string memory _answer) public {
Question[] storage ques = user_questions[_user];
ques[_id].answer = _answer;
}
but I get an error saying
[vm] from: 0x5B3...eddC4 to: AnonAMA.addAnswer(address,uint16,string) 0xdda...5482d value: 0 weight data: 0x0ed...00000 logs: 0 hash: 0xf7c...fdf84
transact to AnonAMA.addAnswer errored: VM error: revert.
revert The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.