upgrade script #7
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the following changes
How to test
Start an anvil instance
Create a
.envfile with the following contentsCreate a
src/StablecoinV2.solfile with the following contentsThis contract will serve as the "new implementation"
Deploy the stablecoin with
Deploy the new implementation with
forge clean forge script script/DeployNewImplementation.s.sol --broadcast --rpc-url http://localhost:8545 \ --sig 'run(string)' StablecoinV2.solUpgrade the contract to the new implementation with the following command (replacing
STABLECOIN_ADDRESSandNEW_IMPLEMENTATION_ADDRESSwith the addresses from steps 4 and 5, respectively)cast send --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --rpc-url http://localhost:8545 \ STABLECOIN_ADDRESS 'upgradeToAndCall(address,bytes)()' NEW_IMPLEMENTATION_ADDRESS 0xTest the upgrade by calling the function
upgradeTest, which is introduced in theStablecoinV2.solcontractcast call STABLECOIN_ADDRESS 'upgradeTest()(uint8)'If the contract was upgraded successfully, then the
upgradeTestfunction will return42.