This question has two parts.
I would like to return a list of items from my smart contract in a simple way, ideally a one-liner solution, something that I consume on the front-end.
I tried some of the products listed here: https://medium.com/coinmonks/top-10-indexed-blockchain-data-apis-providers-3a43da97e54c
(but still dind't find a perfect match)
The objection / difficulty / concern that I have with using The Graph:
- emit ChangeName(...)
- emit ChangeDescription(...)
It feels like additional effort of emitting all the events, then writing handlers to reconcile the current state.
I just want to get the current list of items.
2. Is there a gas limit? (front-end only)
A really simple solution seems to use pragma experimental ABIEncoderV2
function getOrganisations() public view returns(Organisation[] memory) { return organisations; } It generates ABI, my front-end is able to load the data.
view functions don't actually consume gas when they're called from off-chain (because they don't change state)
Will MetaMask / Infura complain about the block size / amount data to return if the array grows to big?
I guess I'll have to try but if this is documented somewhere - please let me know 🙏
EDIT / UPDATE:
This is where I read about the limits: https://ethereum.stackexchange.com/a/121223/2524
Most RPC provider has a gas limit for
eth_callt prevent spam and overloading of their infrastructure. Usually, it's about 2x-3x of the block gas limit. So as long as the gas of the view function is below your RPC providers limit, it should be fine.