0

I have deployed a contract on the ganache blockchain successfully using truffle.

In the truffle console, I can call the contract fine

truffle(development)> MyCoin
[Function: TruffleContract] {
  _constructorMethods: {
    configureNetwork: [Function: configureNetwork],
etc.....

And even get the address like this:

truffle(development)> MyCoin.address
'0xdF7539B8cFA9566B36812ed123b020E633a8a0cf'

However, if I try and get an instance of the contract it returns undefined

truffle(development)> myToken = await MyCoin.deployed()
undefined
truffle(development)> myToken = await MyCoin.new()
undefined
truffle(development)> myToken = await MyCoin
undefined

My goal is to mint the contract, which doesn't work:

truffle(development)> MyCoin.mint(“0x63103644D45820EFb3cEBe188C7dA26F087797b4",100000);
evalmachine.<anonymous>:0
MyCoin.mint(“0x63103644D45820EFb3cEBe188C7dA26F087797b4",100000);
                

Uncaught SyntaxError: Invalid or unexpected token

What could be the problem?

Thanks

  • Is myToken undefined? The result printed on the console is sometimes unrelated to the value being assigned. Also you should execute myToken.mint(...) instead of MyCoin.mint(...). – Ismael Jun 17 '20 at 15:40
  • Thanks for the clarification. Indeed it creates the new instance despite returning undefined, made it work now – vfurci200 Jun 17 '20 at 15:46
0

Still not sure why it returns undefined but this works and creates a new instance on the contract on ganache: truffle(development)> myToken = await MyCoin.new()

The error while minting was just a matter of changing the brackets:

truffle(development)> myToken.mint('0x63103644D45820EFb3cEBe188C7dA26F087797b4',100000)

It works now

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.