I'm using the latest version of Truffle. When I try to compile my contract I get this error. I don't know what is happening

/home/josue/Desktop/blockchain/ebay/contracts/Migrations.sol:20:5: TypeError: Name has to refer to a struct, enum or contract.
    Migrations upgraded = Migrations(new_address);
Compilation failed. See above.
Truffle v5.0.0 (core: 5.0.0)
Node v11.5.0

I don't know what your contract's code contains, but I found this: Getting "TypeError: Name has to refer to a struct, enum or contract." when importing contracts

Hope it helps!


This will probably be flagged as a duplicate. Have a look over here:

TypeError: Name has to refer to a struct, enum or contract when compiling a contract

The Migrations contract is generated automatically with truffle init and it is always compatible with the version of truffle at that time.

I'm guessing someone ran truffle init on an older Truffle, and now you're trying to run with a 0.5.0 compiler (newer).

That means the contracts have to be refactored for Solidity 0.5.0. Alternatively, you could use truffle's new compiler version selector feature to force an older compiler into the picture.

Hope it helps.

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.