0

I am using truffle 5.5.5 with Ganache as my dev blockchain.

When I run truffle migrate I get the following error:

> Compiled successfully using:
   - solc: 0.8.13+commit.abaa5c0e.Emscripten.clang

Starting migrations...

> Network name: 'develop' > Network id: 5777 > Block gas limit: 6721975 (0x6691b7)

1_initial_migration.js

Replacing 'NFTContract'

*** Deployment Failed ***

"NFTContract" -- Invalid number of parameters for "undefined". Got 3 expected 5!.

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

Error: *** Deployment Failed ***

"NFTContract" -- Invalid number of parameters for "undefined". Got 3 expected 5!.

at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:379:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1)
at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:152:1)
at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:117:1)
at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:121:1)
at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:86:1)
at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:78:1)
at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)

UnhandledRejections detected Promise { <rejected> Error: Invalid number of parameters for "undefined". Got 3 expected 5! at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:348:1 at processTicksAndRejections (node:internal/process/task_queues:96:5) at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1) at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1) at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1) at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:152:1) at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:117:1) at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:121:1) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:86:1) at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:78:1) at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1) at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1) { hijackedStack: 'Error: Invalid number of parameters for "undefined". Got 3 expected 5!\n' + ' at Object.InvalidNumberOfParams (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/lib/errors.js:33:1)\n' + ' at Object._createTxObject (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:669:1)\n' + ' at Contract.deploy (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:501:1)\n' + ' at /usr/local/lib/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:275:1\n' + ' at processTicksAndRejections (node:internal/process/task_queues:96:5)' }, _events: Events <[Object: null prototype] {}> {}, emit: [Function: emit], on: [Function: on], once: [Function: once], off: [Function: removeListener], listeners: [Function: listeners], addListener: [Function: on], removeListener: [Function: removeListener], removeAllListeners: [Function: removeAllListeners], _eventsCount: 0 } Error: Invalid number of parameters for "undefined". Got 3 expected 5! at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:348:1

This is my contract:

pragma solidity >=0.7.0 <0.9.0;

import "./IERC165.sol"; import "./IERC721.sol"; import "./IERC721Enumerable.sol"; import "./ERC165.sol"; import "./Strings.sol"; import "./Address.sol"; import "./IERC721Metadata.sol"; import "./IERC721Receiver.sol"; import "./ERC721.sol"; import "./ERC721Enumerable.sol"; import "./Ownable.sol";

contract NFTContracts is ERC721Enumerable, Ownable { using Strings for uint256;

string baseURI; //NFT json is saved string linkURL; string public baseExtension = ".json"; uint256 public cost; // = 0.0 ether; uint256 public maxMintAmount = 1; bool public isInVault = false;

constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); }

// internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; }

Imports are all from openzeppelin.

My 1_initial_migration.js and 2_deploy_contracts.js look like the following:

1_initial_migration.js:

var NFTContract = artifacts.require("../contracts/NFTContract.sol");

// convert ether to wei - https://ethereum.stackexchange.com/questions/124350/how-to-fix-underflow/124354#124354 module.exports = function(deployer) { deployer.deploy(NFTContract, "NFTContract", "NFTContract", "http://localhost:3000/"); };

2_deploy_contracts.js:

var NFTContract = artifacts.require("../contracts/NFTContract.sol");

module.exports = function(deployer) { deployer.deploy(NFTContract, "NFTContract", "NFTContract", "http://localhost:3000/"); };

Any suggestions what I am doing wrong?

I appreciate your replies!

Carol.Kar
  • 130
  • 3
  • 17

1 Answers1

0

You're migrating NFTContract twice, instead you should have Initial migration with Migrations.sol in the contracts directory as:-

const Migrations = artifacts.require("Migrations");
module.exports = function (deployer) {
deployer.deploy(Migrations);
};
waverune
  • 1
  • 2
  • Thank you! What is meant by the "Migrations", how would this look like in my example? – Carol.Kar Mar 27 '22 at 08:59
  • Truffle Migrations are JavaScript files that help you deploy contracts to the Ethereum network. These files are responsible for staging your deployment tasks, and they're written under the assumption that your deployment needs will change over time. https://ethereum.stackexchange.com/questions/8299/what-are-truffle-migrations – waverune Mar 27 '22 at 15:17
  • Truffle does this lifting for you, all you have to do is ' truffle init' at the beginning which creates intial the Migrations for you, then you add the your 2_deploy_contracts.js .... with the deployment params and so on ... if you add more migrations >>> only 3_deploy_contracts.js will run ,the first {1_deploy_contracts.js , 2_deploy_contracts.js} wont – waverune Mar 27 '22 at 15:23
  • If you want to redeploy/run all the migrations again. You can add --reset flag >>> 'truffle migrate --reset' – waverune Mar 27 '22 at 15:24