0

Whenever I truffle deploy my smart contracts, I get a message "duplicate contract names found for undefined". When I then try to interact with them, I get ReferenceError: <contract name> is undefined, for every contract I have deployed.

I'm unable to use 'truffle compile' because of a fairly restrictive work proxy, so I'm using a custom .js script from here and running it with node compile. The contracts are also from that page- contract Dog and contract DogCollection. When I deploy, I use truffle deploy --compile-none to have it deploy the bytecode I've already compiled. I'm guessing this is where the error comes in. How can I modify how the contract names are defined when generating the bytecode?

$ node solcjs --version
0.5.16+commit.9c3226ce.Emscripten.clang

$ truffle version
Truffle v5.3.3 (core: 5.3.3)
Solidity v0.5.16 (solc-js)
Node v10.19.0
Web3.js v1.3.5

1 Answer 1

0

The issue was determined to be in the compile.js script used as a potential workaround. There is a better workaround that actually solves this issue:

Go to https://github.com/ethereum/solc-bin/tree/gh-pages/bin and download your relevant Solidity version compiler. Move this to ~/.config/truffle/compilers/node_modules. This will allow Truffle to use that compiler as part of its built-in compile command, and it will deploy correctly.

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.