In erc20 contracts, conventionally balances
mapping saves the current balance the users are holding.
mapping (address => uint256) private balances;
If this contract has a lot of users( which means that the balances variable is
holding a lot of information) will copying the balances
variable to another variable bad for gas?
If it is bad, will it go over the limit of 'block gas limit'?
How bad is it?
Or is it okay to program it with this kind of design?
I am writing a contract that might have to copy balances
mapping frequently and put it into an array.
like this
mapping (address => uint256) private balances; // this is the variable for token balance
// which holds a lot of information
struct RoyaltyInfo {
mapping (address => uint256) private balances_copy;
uint256 private royalty;
}
RoyaltyInfo[] private royaltyInfomation;
function sendRoyalty() public payable {
royaltyInformation.push(RoyaltyInfo(balances, msg.value)); // pushing current balances state into array
}
If I push balanes
mapping into royaltyInfo
array. Am I copying the variable and putting it in the array or am I just putting the pointer of variable balances
into the array?
Thanks in advance