0

Im trying to create a Token Generator(Token Factory). I dont know how to include the function create in the deploy script. When I excluded

const tx

I deployed a token without name, symbol, decimals and totalSupply but cant deploy a token with name, symbol, decimals and totalSupply.

Here's my contract.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "./TokenFactoryBase.sol";
import "../interfaces/IStandardERC20.sol";

contract StandardTokenFactory is TokenFactoryBase {
  using Address for address payable;
  using SafeMath for uint256;
  constructor(address factoryManager_, address implementation_) TokenFactoryBase(factoryManager_, implementation_) {}

  function create(
    string memory name, 
    string memory symbol, 
    uint8 decimals, 
    uint256 totalSupply
  ) external payable enoughFee nonReentrant returns (address token) {
    refundExcessiveFee();
    payable(feeTo).sendValue(flatFee);
    token = Clones.clone(implementation);
    IStandardERC20(token).initialize(msg.sender, name, symbol, decimals, totalSupply);
    assignTokenToOwner(msg.sender, token, 0);
    emit TokenCreated(msg.sender, token, 0);
  }
}

Here's my deploy.

const {ethers} = require("hardhat");

async function main() {
  const StandardTokenFactory = await ethers.getContractFactory("StandardTokenFactory");

 // const token = await StandardTokenFactory
  const token = await StandardTokenFactory.deploy("0x4D21ED77b4Fc2Df4f4186fc8170FBdDe4b196A51","0x4D21ED77b4Fc2Df4f4186fc8170FBdDe4b196A51");


  await token.deployed();
  
  const tx = await token.create({
         address: "0x4D21ED77b4Fc2Df4f4186fc8170FBdDe4b196A51", 
         name_: "RNCHEY", 
         symbol_:"RNCH", 
         decimals_: "18", 
         totalSupply_: "100000"
  })

  await tx.wait();

  console.log("Token deployed to:", token.address);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Terminal output:

Error: missing argument: passed to contract (count=1, expectedCount=4, code=MISSING_ARGUMENT, version=contracts/5.7.0)

Guys I'm new to programming and would be very grateful if someone helps.

1 Answer 1

0

Try this:

  const tx = await token.create(
         "RNCHEY", 
         "RNCH", 
         "18", 
         "100000"
  )

Basically the arguments must be separated and not in a single structure.

0

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.