Automatic Getter function for dynamic arrays in struct #2955
Replies: 1 comment 1 reply
-
Hi @18121A05L2, ❓ 1. I was facing this issue - The struct has all its members omitted, therefore the getter cannot return any values.✅ Solidity will skip generating getters for mappings and arrays inside structs (with the exception of byte arrays). ❓ 2. I know we need to create separate getter functions, but why won't Solidity create getter functions by default as reading data from storage (blockchain) is free outside of the EVM?✅ It is not possible to access elements in a mapping without specifying a specific key. ❓ 3. It just needs to loop through the entire array and return the values, so why do we have gas costs here (I have checked on Google)?✅ Gas fees help keep the Ethereum network secure. By requiring a fee for every computation executed on the network, gas prevents bad actors from spamming the network. The answer is based on my knowledge, and if there are any mistakes, I welcome any suggestions or corrections from everyone |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions