I have many addresses that map to values in an external program. I want to feed this into a smart contract's state, but I'm wondering what is the most cost-effective way to do this.
Right now I have the simple solution:
function storeValues(address[] addresses, uint[] values) public {
for (uint i = 0; i < addresses.length; i++) {
balances[addresses[i]] = values[i];
}
}
The problem is that balances is a state variable and for each iteration, it saves to this state, which is expensive. I tried to create a temporary mapping inside the function and save to that instead, but apparently, it wasn't possible to create a dynamic mapping like that