I understand that writing data to a smart contract is a transaction and it will cost gas. Will reading data from blockchain cost gas?
For example, I have a struct to collect data about a person - name, age, gender. Now I seeded 1000 persons during contract initialization. Can I query to get all the Persons information? Can I write a function to iterate through the mapping Persons and return all the records? Please let me know if there's any efficient way to do this and if this will cost gas.
struct Person {
uint age;
string name;
string gender;
}
mapping(uint => Person) Persons;
mapping. (You need to know the keys some other way.) – user19510 Nov 25 '17 at 06:35