4

I'm following this tutorial. After using the command truffle migrate --reset the blocks appear on Ganache GUI. However, I'm not able to interact with the contract using the console. If I type token = await MemoryToken.deployed(), I receive the following error:

truffle(development)> let token = await MemoryToken.deployed()
Uncaught ReferenceError: global is not defined at evalmachine.<anonymous>:2:19

I have no idea why. I tried this several time with the same result. What am I missing ?

The same happens with the tutorial from the truffle website.

Caladay
  • 111
  • 6
  • Great question. Just started experiencing this as well. I can test it via truffle test, but can't interact with it via truffle console (after I manually migrate). Same error. – iolympian Aug 09 '21 at 01:58
  • 2
    downgrade the truffle version to 5.4.3 – ovo Aug 09 '21 at 09:20
  • @ovo It works thank you very much. Do you have any idea why this happen with truffle v5.4.5 ? – Caladay Aug 09 '21 at 09:28

4 Answers4

9

A temporary workaround is to explicitly define global in the REPL:

global = this
Muhammad Shuja
  • 642
  • 5
  • 18
4

Try

truffle(development)> let token = MemoryToken.deployed()

It worked for me. I don't know much more about the error

0

I had same issue. Changed node version from v12.22.4 to v10.16.0.

0

I had the same problem in the MetaCoin example with Truffle v5.4.5 (core: 5.4.5), Solidity v0.5.16 (solc-js), Node v14.14.0, Web3.js v1.5.1. It works after downgrading Truffle to version v5.4.3 as suggested by @ovo.