Cyfrin / foundry-defi-stablecoin-cu

250 stars 117 forks source link

ERC20Mock Parameters #37

Closed Mubasher-dv closed 9 months ago

Mubasher-dv commented 1 year ago

I have been following Patick's StableCoin project.

The issue I am facing right now is that when he is using ERC20Mock, This contract needs four parameters to make a wethMock and wbtchMock, but now this contract doesn't need any parameters. So, how can I solve this issue to carry on this project?

ERC20Mock wethMock = new ERC20Mock("WETH","WETH", msg.sender, 1000e8);

ERC20Mock.sol

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

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);
}

}

usmanfarooq91 commented 1 year ago

Follow the instructions here.

Mubasher-dv commented 1 year ago

Thanks bro

DMG-01 commented 1 year ago

how did you go about i am stuck rn and i followed the instruction but it doesnt seem to work

danilvoe00 commented 1 year ago

Thanks bro

Hi what instructions are you guys talking about and how did you go about solving the issue

danilvoe00 commented 1 year ago

how did you go about i am stuck rn and i followed the instruction but it doesnt seem to work

Did you solve the proble if you did please help me.

usmanfarooq91 commented 1 year ago

Hi what instructions are you guys talking about and how did you go about solving the issue

In the latest version of openzeppelin/openzeppelin-contracts ERC20Mock.sol file has been updated with 0 constructor parameters. You should use forge install openzeppelin/openzeppelin-contracts@v4.8.3 --no-commit command to download the appropriate version synced with the video.

danilvoe00 commented 1 year ago

Hi what instructions are you guys talking about and how did you go about solving the issue

In the latest version of openzeppelin/openzeppelin-contracts ERC20Mock.sol file has been updated with 0 constructor parameters. You should use forge install openzeppelin/openzeppelin-contracts@v4.8.3 --no-commit command to download the appropriate version synced with the video.

thank you

sunnyStefi commented 1 year ago

You can also personalise the ERC20Mock contract inside the openzeppelin library, making your own WETH20Mock contract, where you mint and set the desired test balance inside the constructor.

E.g.:

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

contract ERC20MockWETH is ERC20 {

    constructor(address _owner) ERC20("ERC20MockWETH", "WETH") {
        _mint(_owner, 100e10);
    }

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

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