Deployment failed using truffle for ERC20 token

I made a contract, compiled it, and when I enter truffle migrate --reset, this comes out. what to do?)

1 Like

Hi @Andrei,

It looks like you are not providing the parameter the constructor of your smart contract is expecting.

See the Truffle documentation on how to provide the constructor paramenters:

https://www.trufflesuite.com/docs/truffle/getting-started/running-migrations#deployer-deploy-contract-args-options-

// Deploy a single contract without constructor arguments
deployer.deploy(A);

// Deploy a single contract with constructor arguments
deployer.deploy(A, arg1, arg2, ...);

If you can share your smart contract and migrations script 2_deploy_mytoken.js I am happy to take a look.

1 Like
const MyToken = artifacts.require("MyToken");

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

1 Like

1 Like

Hi,
the constractor expects an initialSupply from type uint265. So that’s the missing variable that is causing the “undefined” error Got 0 expected 1. Because you did not pass this argument it will be interpreted as “undefined”

Assume you have 1000 wei as initialSupply try this:

const MyToken = artifacts.require(“MyToken”);

module.exports = function(deployer) {
deployer.deploy(MyToken, 1000);
};
2 Likes

thanks, it turned out :slight_smile:

2 Likes

please tell me which test do I need to write in my contract?)

1 Like

Hi @Andrei,

The following article is a great resource:

Also look at the OpenZeppelin Contracts tests: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/test/token/ERC20

1 Like

thanks, I’ll try now … :slight_smile: