How do I upgrade smart contract if I want to add 1 more library. Like today I am using Oraclize. After someday I want to use Chainlink to. How do I do that?
Thanks for posting this question in the forum and welcome to the community .
My (basic) understanding of oracles such as Provable and Chainlink is that your contract inherits from their API contract, you have a state variable e.g. an exchange rate and a function that you can call to get an updated value from the oracle and a callback function that the oracle calls to set the value.
I believe that there are potentially two options to support changing oracle suppliers:
Separate the oracle functionality into a contract, and your main contract can call this contract via an interface to get the value. If you change oracle provider, you can create a new contract with the same interface and change the main contract to call this new contract.
Include the oracle functionality in your upgradeable contract though reserve storage slots so that an upgraded version of your contract using a different oracle doesn’t mix up storage values.
See the documentation for more information on Modifying your contracts.
I am new to oracles, so feel free to ask followup questions and I will see what information I and the community can provide.
I think that this is the most robust solution! I am not familiar with the details of the Chainlink or Provable base contracts, so there is a chance that (2) may not work - changing base contracts can be somewhat tricky if you are not careful with the storage layout.
I wanted to check if the above answered your question or whether you needed more information?
I am implementing the given approaches soon. I need to check which works the best for me.