I'm considering different designs to implement "configuration options" with Ethereum.

The design should allow me to define arbitrary (= number and type) options, quick access to a list of options, their values, and validated change of options values.

A naive design would be one contract per config option. That would be a lot of contracts.

Right now, I'm wondering about a design where I store JSON and JavaScript code in the contract. The JSON would allow me to define arbitrary options and their values. The JavaScript could be fetched from the contract in web3.js to validate changes to the configuration.

This would, like using normal contracts, allow to share the same code base between all parties. It should be pretty efficient (unless there is a problem with huge strings?).

So far, I'm seeing two drawbacks:

  • I couldn't use those config options in the smart contracts directly.
  • A malicious party could to submit illegal values (by simply ignoring the validation)

The first one can be solved by adding extra fields in the contracts and keep the values in sync (with all the problems that brings).

The second could be mitigated by people running the validation before trusting config values.

To make this work, I'd need to use eval(). To make this secure, I need to control who can change the JavaScript fields of a contract.

Am I missing something?

  • I'd like to add the tags json and smart-contract but don't have enough reputation. Nov 29, 2019 at 11:42

1 Answer 1


Are your strings going to be memory or storage? It can be expensive to use large strings as storage in terms of gas fees, as you have to pay to make other nodes retain that information. I'm not quite sure what you're building, but it often makes more sense to use hashes of large strings, and then store the data somewhere else. Other parties can check the data's integrity by verifying the hash against the smart contract.

  • Definitely storage since I want to distribute the data to all parties. According to this, that would cost about $1/KB at the current ETH rate of $150. Dec 2, 2019 at 10:06

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.