Skip to content

Instantly share code, notes, and snippets.

@basilche
Last active July 10, 2019 10:27
Show Gist options
  • Save basilche/f1c991aa1f9e9f36dea904c37db683fa to your computer and use it in GitHub Desktop.
Save basilche/f1c991aa1f9e9f36dea904c37db683fa to your computer and use it in GitHub Desktop.
# 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