Skip to content

Conversation

@ricomateo
Copy link
Contributor

@ricomateo ricomateo commented Dec 17, 2025

This PR introduces the following changes

  • Adds a script that deploys a new stablecoin implementation for upgrades.
  • Adds instructions for upgrading a stablecoin contract using a Safe multisig.
  • Improves the stablecoin contract deployment script.

How to test

  1. Start an anvil instance

  2. Create a .env file with the following contents

    PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
    STABLECOIN_NAME=Stablecoin
    STABLECOIN_SYMBOL=Stablecoin
    ADMIN_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
    BURNER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
    PAUSER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
    FREEZER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
  3. Create a src/StablecoinV2.sol file with the following contents

    // SPDX-License-Identifier: UNLICENSED
    pragma solidity ^0.8.13;
    import {Stablecoin} from "src/Stablecoin.sol";
    
    /// @custom:oz-upgrades-from Stablecoin
    contract StablecoinV2 is Stablecoin {
        function upgradeTest() public pure returns (uint8) {
            return 42;
        }
    }

    This contract will serve as the "new implementation"

  4. Deploy the stablecoin with

    forge clean
    forge script script/DeployStablecoin.s.sol:DeployStablecoin  --broadcast --rpc-url http://localhost:8545
  5. Deploy the new implementation with

    forge clean
    forge script script/DeployNewImplementation.s.sol --broadcast --rpc-url http://localhost:8545 \
    --sig 'run(string)' StablecoinV2.sol
  6. Upgrade the contract to the new implementation with the following command (replacing STABLECOIN_ADDRESS and NEW_IMPLEMENTATION_ADDRESS with 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 0x 
  7. Test the upgrade by calling the function upgradeTest, which is introduced in the StablecoinV2.sol contract

    cast call STABLECOIN_ADDRESS 'upgradeTest()(uint8)'

    If the contract was upgraded successfully, then the upgradeTest function will return 42.

@ricomateo ricomateo marked this pull request as ready for review December 17, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants