Ben 4 months ago

Where to add/upgrade functions?

At about 25:30 into the video, you add the “intVal” variable and tell us that we cannot delete existing variables and that new ones must be added after the existing variables.  Understood.

How about new or upgraded functions?  Can existing functions be modified in place?  Do new functions have to be added after the existing functions or can they be mixed into the existing function code structure?

  1. 1
    Jack Wu
    Jack Wu 4 months ago
    Hi Ben, yes you can upgrade the entire contract. Essentially you’re deploying a new contract and just setting the new contract address in the proxy contract. The only thing is that when you upgrade, the state of the old contract is not preserved in the new contract. If you want to migrate state from old contract to new contract, then you can use a different approach. Take a look at this article for more info.