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?
json
andsmart-contract
but don't have enough reputation.