Invalid number of parameters for "undefined". Got 1 expected 2 while deploying ERC721 Token Contract

Hello,

I’m a beginner developing simple dapps using smart contracts. I am getting the below error while trying to deploy ‘MyNFToken.sol’ contract using the command ‘npx oz create’.

Error: Invalid number of parameters for "undefined". Got 1 expected 2!

I tried deploying other smart contracts using the above create command and it works so far. Please help me to resolve this issue.

Contract code:

pragma solidity ^0.4.20;

import "./NFTokenMetadata.sol";
import "../node_modules/@0xcert/ethereum-utils/contracts/ownership/Ownable.sol";

contract MyNFToken is NFTokenMetadata, Ownable {
    address myContract;

    function MyNFToken(string _name, string _symbol) public {
        nftName = _name;
        nftSymbol = _symbol;
    }

    function mint(address _owner, uint256[] _id)
        external
        onlyOwner
        returns (uint256)
    {
        for (uint256 i = 0; i < _id.length; i++) {
            super._mint(_owner, _id[i]);
        }
    }

    function mint2(address _owner, uint256[] _id) external returns (uint256) {
        for (uint256 i = 0; i < _id.length; i++) {
            super._mint2(_owner, _id[i]);
        }
    }

    function getb(address _owner) public returns (uint256[], uint256[]) {
        return (super._getb(_owner));
    }

    function burn(address _owner, uint256 _tokenId) external //onlyOwner
    {
        super._burn(_owner, _tokenId);
    }
}

Environment:

Truffle v4.1.10
Solidity:0.4.24
Node: 10.19.0
Npm: 6.14.4

1 Like

Hi @kottackalsulvin,

Welcome to the community :wave:

The error looks like you are only providing 1 parameter, when your contract takes two parameters in its constructor, a name and a symbol.

The contract you provided uses Solidity 0.4. I would suggest using a later example/tutorial.
You may want to look at the following tutorial: [DRAFT] Create an NFT and deploy to a public testnet, using Truffle

As a beginner you may also want to look at the OpenZeppelin Learn guides: https://docs.openzeppelin.com/learn/

Please note we’ve decided it’s best to focus our upgradeability efforts on the Upgrades Plugins exclusively, and have halted development on the OpenZeppelin CLI. (See: Building for interoperability: why we’re focusing on Upgrades Plugins)

@abcoathup thanks for your reply, that solved my ‘invalid parameter’ error.

But I am getting the below error, when i am confirming the transaction in metamask (while creating erc721 and erc20 tokens).

MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC

1 Like

1 Like

Hi @kottackalsulvin,

You are getting Exceeds block gas limit.

What tool are you using to deploy your contract?
What network are you deploying your token to?

Hi @kottackalsulvin,

Are you still having issues?

@abcoathup Both erc20 and erc721 contracts get deployed. But I am still facing some issues.
I am not able to initialize the values in erc20 contract (not getting the initialized values). I am using openzeppelin cli (‘npx oz create’ command for deploying contract).

Contract Code

// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------

   contract SafeMath {
    function safeAdd(uint a, uint b) public pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }
    function safeSub(uint a, uint b) public pure returns (uint c) {
        require(b <= a);
        c = a - b;
    }
    function safeMul(uint a, uint b) public pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }
    function safeDiv(uint a, uint b) public pure returns (uint c) {
        require(b > 0);
        c = a / b;
    }
}


// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// ----------------------------------------------------------------------------
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);
}

// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
    address public owner;
    address public newOwner;

    function Owned() public{
        owner = msg.sender;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    function transferOwnership(address _newOwner) public onlyOwner {
        newOwner = _newOwner;
    }
    function acceptOwnership() public {
        require(msg.sender == newOwner);
      emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
        newOwner = address(0);
    }
}


contract ERC20 is ERC20Interface, Owned, SafeMath {
    string public symbol;
    string public  name;
    uint8 public decimals;
    uint public _totalSupply;
    address public mainAddress;

    mapping(address => uint) balances;
    mapping(address => mapping(address => uint)) allowed;

    function ERC20() public {
        symbol = "KBS";
        name = "KBS";
        decimals = 0;
        _totalSupply = 10000000000;
        balances[msg.sender] = _totalSupply;
        mainAddress = msg.sender;
    }
}
1 Like

Hi @kottackalsulvin,

Please note: We’ve decided it’s best to focus our upgradeability efforts on the Upgrades Plugins exclusively, and have halted development on the OpenZeppelin CLI. We will continue to provide support for the CLI until the end of 2020.
See: Building for interoperability: why we’re focusing on Upgrades Plugins

If you want to deploy an upgradeable contract you can use OpenZeppelin Upgrades Plugins with either Truffle or Hardhat: https://docs.openzeppelin.com/upgrades-plugins/1.x/

If you want to deploy a non-upgradeable contract you can use Truffle, Hardhat or Remix. See: https://docs.openzeppelin.com/learn/deploying-and-interacting

@Thanks for your reply.
I deployed my contract using Oz upgrades plugin( with Truffle).
But while upgrading my ‘stats’ contract, I got the below error:

Error: Contract `Stats` is not upgrade safe

Stats.sol:8: Defining structs like `sports` is not yet supported
    If you have manually checked for storage layout compatibility, you can skip this check with the `unsafeAllowCustomTypes` flag
    https://zpl.in/upgrades/error-007

Contract Code (stats.sol)

contract stats {
struct sports {
        bytes sportsHash; 
    }
mapping(bytes32 => sports) SportsTable;
bytes32[] sport;

function saveSportsDetailsToIPFS(bytes32 sportsName,bytes hash) public returns(bool) {
        SportsTable[sportsName].sportsHash = hash;
        sport.push(sportsName);
        return true;
    }
function getSportsList() public returns(bytes32[]) {
        return sport;       
    }
}

Upgradeable Contract Code(stats2.sol)

contract stats2 {
struct sports {
        bytes sportsHash; 
    }
mapping(bytes32 => sports) SportsTable;
bytes32[] sport;

function saveSportsDetailsToIPFS(bytes32 sportsName,bytes hash) public returns(bool) {
        SportsTable[sportsName].sportsHash = hash;
        sport.push(sportsName);
        return true;
    }
function getSportsList() public returns(bytes32[]) {
        return sport;       
    }
function getSportsHash(bytes32 sportsName) public returns(bytes) {
    return (SportsTable[sportsName].sportsHash);       
}
}

How can I resolve this issue?

1 Like
Error: Contract TruffleContract does not have a function `initialize`
    at getInitializerData (/home/user/Documents/Sports06Febbb/Sports06Feb-oz/Sports/node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:86:11)
    at deployProxy (/home/user/Documents/Sports06Febbb/Sports06Feb-oz/Sports/node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:60:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.57 (core: 5.1.57)
Node v10.19.0

I am also getting the above error while deploying contracts using oz upgrades plugins with truffle…

1 Like

Hi @kottackalsulvin,

Regards using structs, please see the documentation:

Regards initialize, you can check your migrations script for which function you are calling in deployProxy to initialize your contract.
See: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades#migrations-usage