3

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.

1
  • 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!
    – q9f
    Commented Jan 6, 2017 at 13:11

1 Answer 1

5

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.

4
  • 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? Commented Jan 7, 2017 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. Commented Jan 7, 2017 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 Commented Jan 7, 2017 at 19:28
  • Today you should be fine if you have less than 100 GB data. Commented Jan 7, 2017 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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