I have a mapping in contractA marked as public. I know a default getter function is created that will allow me to get the value from contractB, but can I set the value from contractB too? The compile error I'm getting isn't clear "TypeError: Expression has to be an lvalue." so I'm just wondering if I have the syntax wrong or if it's simply not possible even though it's marked as public.
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.7.0 <0.9.0;
contract contractAInterface {
mapping(string => uint256) public testMapping;
}
contract contractB {
address contractAddress = 0xd9145CCE52D386f254917e481eB44e9943F39138;
contractAInterface contractA = contractAInterface(contractAddress);
function setValueOfMapping(string memory _key, uint256 _value) public {
contractA.testMapping(_key) = _value;
}
}