0

We are developing a decentralized application on Ethereum that manages surveys.

We have a main smart-contract that contains survey information (i.e. hashes) as well as 2 main functions: one to create a new survey and one to participate to the survey.

This contract is becoming too large (+- 250 lines) so we would like to split it into several smaller contracts.

The challenge is that our functions all need to access the data that is stored in the main contract so we can't move functions to another contract (it would no longer have access to the data).

So we thought using a proxy mechanism. A proxy contract would store data and transfer calls to functions by delegate calls to different contracts.

Before we start implementing this architecture, we would like to know if:

1- Is this architecture/design correct?

2- What other options are available to us?

Thank you for your help

1

I'd say it is pretty common approach, I'd move data struct to libraries and import them in the main contract if the methods are declared external the compiler will use delegatecall automatically.

Another alternative is to not store your data onchain only some proof of it and only submit your data whit it is needed. This approach only applies to some problems so it might be difficult or impossible to implement. If you want to learn search for stateless smart contract.

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.