I am making upgradeable erc20 smart contract using chugsplash as upgrader and foundry as framework. It's name is FractionToken.sol and has it test contract FractionToken.t.sol.

It went well(The contract deployed successfully and the test ran successfully) before I implement the chugsplash to the contract.

FYI: I am new both to smart contract and using chugsplash

when implementing the chugsplash to FractionToken.sol and did some corrections to how the contract(FractionToken.sol) constructor defined, eventually It's deployed using chugsplash successfully in localhost using anvil.

successfully deploy upgradeable smart contract locally

But, the problem now is in Testing, on of the problem is, functions that were defined in FractionToken.sol that has onlyOwner modifier, now reverts with error ([FAIL. Reason: Ownable: caller is not the owner]). So I tried to debug, in FractionToken.t.sol,

in FrractionToken.t.sol:

contract FractionTokenTest is Test {
    FractionToken fractionToken;

function setUp() public virtual {
        // Create a ChugSplash instance
        ChugSplash chugsplash = new ChugSplash();

        // Define the path from the project root to your ChugSplash file.
        string memory chugsplashFilePath = "./chugsplash/hello-chugsplash.json";

        // Deploy all contracts in your ChugSplash file
        chugsplash.deploy(chugsplashFilePath, true);

        // You *must* refresh EVM state after calling `chugsplash.deploy`.

        fractionToken = FractionToken(
                chugsplash.getAddress(chugsplashFilePath, "<MY SC REFERENCE NAME>")

And on of the tests, I consolelog:

// returns 0x7Fdfb1eF01b5B4bC59F5D7FF2530f2dC4E1889E6

//returns 0x0000000000000000000000007fdfb1ef01b5b4bc59f5d7ff2530f2dc4e1889e6

Why they return basically the same address only that the other has "0x000000000000000000000000" as prefix and this made the test reverted with error as mentioned above.

1 Answer 1


Hi developer advocate from Chainstack here

The return data seems to be 32-byte, are you using bytes32 type to store the address instead of address type?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.