0

Im building defi token Im developing it with reference cource in which the educator is using openzeppelin version 4.8.3 in which ERC20Mock contract takes 4 parameters , but right now there is only version 5.0.2 of openzepplin is available in which ERC20Mock.sol takes only 2 parameters.

Here is the HelperConfig script code that Patrick used:

import { ERC20Mock } from "@openzeppelin/contracts/mocks/ERC20Mock.sol";

        vm.startBroadcast();
        MockV3Aggregator ethUsdPriceFeed = new MockV3Aggregator(DECIMALS, ETH_USD_PRICE);
        ERC20Mock wethMock = new ERC20Mock("WETH", "WETH", msg.sender, 1000e8);

        MockV3Aggregator btcUsdPriceFeed = new MockV3Aggregator(DECIMALS, BTC_USD_PRICE);
        ERC20Mock wbtcMock = new ERC20Mock("WBTC", "WBTC", msg.sender, 1000e8);
        vm.stopBroadcast();
        

And this is the ERC20Mock.sol contract in the latest latest openzeppelin v5.0.2

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC20} from "../../token/ERC20/ERC20.sol";

contract ERC20Mock is ERC20 {
    constructor() ERC20("ERC20Mock", "E20M") {}

    function mint(address account, uint256 amount) external {
        _mint(account, amount);
    }

    function burn(address account, uint256 amount) external {
        _burn(account, amount);
    }
}

Can someone help me figure out how i can resolve this issue ?

1 Answer 1

0

There are multiple ways you can handle this, don't try to copy the tutorial as it is.

  1. Just remove those two unwanted arguments from the script.

         ERC20Mock wbtcMock = new ERC20Mock("WBTC", "WBTC");
    
  2. Use the previous version of OZ, where it takes 4 parameters.

  3. Just create your mock contract and include 4 parameters in it, if you don't wanna use an older version of OZ.

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.