0

I'm trying to us a contract in a truffle project. This is part of a migration.js file.

deployer.deploy(token,companyID).then(function(){
    var starttime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 300000000;
    var endtime = starttime + 1000000;
    GG = token;
    return deployer.deploy(tokenICO, token.address, tokenwallet, rate, goal, tokenwallet, starttime, endtime).then(function()
    {

        console.log("token object: " + token);
        GG.approve(tokenICO.address,16000000);
    });
});

In this case I want to use the approve function of the token contract but I get the following error:

TypeError: GG.approve is not a function
at (location)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)

Is there an alternative way of going about this?

2
  • Is GamerGold a contract? Is it deployed? May 4, 2018 at 21:16
  • GamerGold was a typo it should be correct now. May 4, 2018 at 22:30

1 Answer 1

1

You could do in this way.

 var GG;
 deployer.deploy(token,companyID).then(function(){
  var starttime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 300000000;
  var endtime = starttime + 1000000;
return deployer.deploy(tokenICO, token.address, tokenwallet, rate, goal, tokenwallet, starttime, endtime).then(function()
{
    token.deployed().then((inst)=> {
    GG = inst;
    console.log("token object: " + token);
    GG.approve(tokenICO.address,16000000);
  });

});
});
1
  • Another valid alternative was in a deleted answer: token.at(token.address).approve(tokenICO.address,16000000);
    – Ismael
    May 5, 2018 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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