1

This is a token maker code, so its failing to deploy with the following reason:

> *** Deployment Failed ***

"TokenMaker" hit an invalid opcode while deploying. Try:
   * Verifying that your constructor params satisfy all assert conditions.
   * Verifying your constructor code doesn't access an array out of bounds.
   * Adding reason strings to your assert statements.


Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.


Error:  *** Deployment Failed ***

"TokenMaker" hit an invalid opcode while deploying. Try:
   * Verifying that your constructor params satisfy all assert conditions.
   * Verifying your constructor code doesn't access an array out of bounds.
   * Adding reason strings to your assert statements.

This is the code below

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
    address private _owner;
    uint8 private _decimals;
    uint256 private _totalSupply;
    
    constructor(string memory name_, string memory symbol_, address _tOwner, uint8 decimals_, uint256 _tSupply) ERC20(name_, symbol_) {
        _owner = _tOwner;
        _decimals = decimals_;
        _totalSupply = _tSupply * (10 ** uint256(decimals()));
        _mint(_owner, _totalSupply);
    }

    function owner() public view returns(address){
        return _owner;
    }
    function decimals() public view override  returns(uint8){
        return _decimals;
    }

    function totalSupply() public view override returns(uint256){
        return _totalSupply;
    }

}
contract TokenMaker{
    uint256 public baseFee = 0.0005 ether;
    mapping(address => address) private _myToken;
    address public owner;
    bool locked;

    constructor(){
        owner = msg.sender;
    }

    function create(
        string memory _name,
        string memory _symbol,
        address _owner,
        uint8 _decimals,
        uint256 _totalSupply
        ) public payable{
            require(msg.value == baseFee, "Insufficient Fee");
            _myToken[msg.sender] = address(new Token(
               _name,
               _symbol,
               _owner,
               _decimals,
               _totalSupply
            ));
        }

    function withdraw() public {
       require(!locked, "Locked");
       require(owner == msg.sender, "Not owner");
       require(address(this).balance > 0, "Insufficient contract balance");
       locked = true;
       payable(owner).transfer(address(this).balance);
       locked = false;
    }

    function myToken() public view returns(address){
        return _myToken[msg.sender];
    }
}

this is the deployment script:

const TokenMaker = artifacts.require('TokenMaker');
const Token = artifacts.require('Token');

module.exports = function(deployer){
   
    deployer.deploy(TokenMaker);
}
1

0

Your Answer

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

Browse other questions tagged or ask your own question.