Last active
July 10, 2019 10:27
-
-
Save basilche/f1c991aa1f9e9f36dea904c37db683fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create logic contract | |
let myContract1 = await MyContract1.new() | |
# create a proxy which reference the logic contract | |
let proxy = await AdminUpgradeabilityProxy.new(myContract1.address) | |
# wrap proxy with the contract API | |
var wrapper = await MyContract1.at(proxy.address) | |
# initialize the contract | |
await wrapper.initialize(42) | |
console.log(await wrapper.value()) // 42 | |
# create new logic contract | |
let myContract2 = await MyContract2.new() | |
# upgrade proxy to refer to the latest version | |
await proxy.upgradeTo(myContract2.address) | |
# use API of the new contract version | |
wrapper = await MyContract2.at(proxy.address) | |
await wrapper.add(1); | |
console.log(await wrapper.value()) // 43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment