0

enter image description hereenter image description here

I am creating a new Blockchain wallet with ERC20,but during migration,i am getting the error that tokenMock.mint is not a function(tokenMock is the deployed contract)

I am sending the tokens to my account,and then calling the smart Contract with the same account,as it is showing that tokenMock.mint is not a function,so the tokens are not being transferred and hence the balance is 0.

  • I am new to the Ethereum world,so it can be a silly error. – Arun Pratap Singh Jul 31 at 14:46
  • const Migrations = artifacts.require("Migrations"); const DaiTokenMock = artifacts.require("DaiTokenMock"); module.exports = async function(deployer) { await deployer.deploy(Migrations); await deployer.deploy(DaiTokenMock); const tokenMock = await DaiTokenMock.deployed(); //Mint 1000 dai fro the deployer await tokenMock.mint( "0x07f073f498fce632f0c177c1c558f0c09e8e0f96", "100000000" ); }; The migration code,where i am transferring the tokens – Arun Pratap Singh Jul 31 at 14:50
0

The problem is that deployed() will not work until the migrations script has completed, but you have access to deployed address and create an instance pointing to it.

module.exports = async function(deployer) {
  await deployer.deploy(Migrations);
  await deployer.deploy(DaiTokenMock);

  const tokenMock = await DaiTokenMock.at(DaiTokenMock.address);

  //Mint 1000 dai fro the deployer
  await tokenMock.mint( "0x07f073f498fce632f0c177c1c558f0c09e8e0f96", "100000000" );
}; 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.