I have a contract that stores some basic data about a person. It has about 4-5 variables. Each of these contracts is associated with a name.

Say I want to search for a Person smart contract that belongs to Varun, then I can call every single contract, and query whether the it has that name stored or not. Now this is very in-efficient so instead I want to have a CentralRegistry contract in which I can keep a basic mapping of the name vs the address of the contract it belongs to.

Every time a new contract is created, the name and address corresponding to it is appending to the mapping in the CentralRegistry contract. If I have 10,000,000 Person contracts, is there any issue is storing a mapping that has 10million registry. Note each append to the mapping will be done in a separate transaction, and it will be probably done over several months.

  • It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks!
    – Afr
    Jan 6 '17 at 13:11

Store your CentralRegistry look up data as mapping. mapping can practically store unlimited amount of data without slowing down. Blockchain size growth should not be an issue for mere 10 million entries and current node softwares handle it easily.

Alternative make the look up data available using Events like Event PersonAdded(string indexed name). Indexed event parameters have native lookup in Ethereum JSON-RPC API, however events look up API is not exposed to smart contracts themselves. More about events.

  • 1
    Events in smart contracts can be listened to by web3.js. However this requires me to have the contract's address before adding the listener. Does this mean for 10million contracts, I will effectively have 10million events registered in web3.js code? You mentioned for mere 10million entries blockchain size growth won't be a problem. Any idea when it will start posing an issue? How many entries would be needed for it to be a concern? Jan 7 '17 at 8:31
  • You can scan events for any contract, you don't need to know the address beforehand, only sha3 signature of the event. Jan 7 '17 at 19:26
  • The future versions of Ethereum are going to scale through a mechanism called sharding (among others) - and should not have practical limits in blockchain size: coindesk.com/ethereum-creator-vitalik-buterin-scaling-devcon2 Jan 7 '17 at 19:28
  • Today you should be fine if you have less than 100 GB data. Jan 7 '17 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.