I am trying to deploy my smart contract. When I run truffle compile everything works however when I run truffle migrate, I get this occurring error message:

Error: * Deployment Failed *

"KJToken" -- Invalid number of parameters for "undefined". Got 1 expected 0!.

I have tried to delete my build folder and reset my compilations but nothing is working. Even when I try to reset my truffle migration the same error shows up.

Here is my deploy contracts.js code:

var KJToken = artifacts.require('./KJToken.sol')
module.exports = function (deployer) {
  deployer.deploy(KJToken).then(function () {
    return deployer.deploy(KJToken, KJToken.address)

Here is my kjtoken.sol

pragma solidity >=0.4.21 <0.7.0;

contract KJToken {
    string public name;
    string public symbol;
    uint8 public decimals;
    uint256 public totalSupply;

    //balances for each account
    mapping(address => uint256) balances;
    address devAddress;

    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
    event Transfer(address indexed from, address indexed, uint256 value);

    // owner of account approves the transfer of an amount to another account
    mapping(address => mapping (address => uint256)) allowed;
    // contructor is automattically going to run when the smart contract is uploaded
    constructor() public {
        name = "KJtoken";
        symbol = "KJ";
        decimals = 18;
        devAddress = 0x22391dc3a3cD8e9774F426e5405C3440559D0a1e;
        uint initialBalance = 1000000000000000000*1000000; // 1M tokens
        balances[devAddress] = initialBalance;
        totalSupply += initialBalance; //set the total supply

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];

    //Transfer the balance from owner's account to another account
    function transfer(address _to, uint256 _amount) public returns (bool success) {
        if (balances[msg.sender] >= _amount
            && _amount > 0
            && balances[_to] + _amount > balances[_to]) {
            balances[msg.sender] = _amount;
            balances[_to] += _amount;
            emit Transfer(msg.sender, _to, _amount);
            return true;
        } else {
            return false;
    function transferFrom(
    address _from,
    address _to,
    uint256 _amount
) public returns (bool success) {
    if (balances[_from] >= _amount
        && allowed[_from][msg.sender] >= _amount
        && _amount > 0
        && balances[_to] + _amount > balances[_to]) {
        balances[_from] -= _amount;
        allowed[_from][msg.sender] -= _amount;
        balances[_to] += _amount;
        return true;
    } else {
        return false;

// allow _spender to to withdraw from your account, multiple times, up to the _value amount.
// if this functin is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount) public returns (bool success) {
    allowed[msg.sender][_spender] = _amount;
    emit Approval(msg.sender, _spender, _amount);
    return true;


2 Answers 2


You are passing 1 argument in an attempt to deploy an instance of contract KJToken:

deployer.deploy(KJToken, KJToken.address)

But the constructor of this contract takes 0 arguments:

constructor() public ...
  • Hello, so how would I change the constructor of the contract to take that 1 argument?
    – Kaya Jones
    Commented May 6, 2020 at 12:12
  • @KayaJones: Do you really need this constructor to take 1 argument (let alone, according to your migration code, the address of some other KJToken contract instance)??? Commented May 6, 2020 at 12:13
  • I guess not, I'm new to learning how to build smart contracts. But anyway does this mean that I would need to make my deployer take no arguments as well?
    – Kaya Jones
    Commented May 6, 2020 at 12:23
  • @KayaJones: if your contract's constructor takes no argument, then the deployer should obviously not pass any arguments to it. But it sounds to me like you should learn how Truffle Deployer works, because it makes very little sense to do something like deployer.deploy(KJToken, KJToken.address), regardless of the fact that the constructor doesn't take any arguments (i.e., even if it took one argument). Commented May 6, 2020 at 12:26

This is because your constructor does not accept any parameters.

Change your contract.js file to this:

var KJToken = artifacts.require("KJToken.sol");
module.exports = function (deployer) {

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.