Skip to content

calldelegation/sway-contract-upgrade-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sway-contract-upgrade-example

Simple example of how to upgrade contracts in Sway

  1. Add proxy functionality to Forc.toml
[proxy]
enabled = true
  1. Deploy the contract using forc deploy
forc deploy --mainnet

You will notice an address in your forc.toml under [proxy] file after the deployment, this is your proxy contract address.

[proxy]
enabled = true
address = "0x33f45975f14434a7950446ce9c4cbbc64e5d3ffb5c5a8e7a9dce3f05ae962442"
  1. Go to Sway-Playground and paste the abi in out/debug/sway-contract-upgrade-example-abi.json as well as the address to interact with get_version function and verify that the number is 7.

deploy-1

  1. Change line 3 in src/main.sw to a new number
const VERSION: u8 = 2u8;
  1. Redeploy the contract using forc deploy again
forc deploy --mainnet
  1. Go back to Sway-Playground and verify that the number is now your new number.

deploy-2

  1. Congratulations! You just upgraded your first contract in Sway!

About

Simple example of how to upgrade contracts in Sway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages