Related issue on GitHub: https://github.com/trufflesuite/truffle/issues/3329

If I compile my contracts with truffle compile and then open the truffle console with truffle develop then this happens:

truffle(develop)> version
Truffle v5.1.39 (core: 5.1.39)
Solidity - ^0.6.0 (solc-js)
Node v12.18.2
Web3.js v1.2.1
truffle(develop)> TypeError: Buffer.isBuffer is not a function
    at Function.writeFileSync [as sync] (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/write-file-atomic/index.js:213:1)
    at Configstore.set all [as all] (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/configstore/index.js:58:1)
    at new Configstore (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/configstore/index.js:25:1)
    at Function.getUserConfig (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:171:1)
    at Object.send (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/services/analytics/index.js:5:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:137:1)
    at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:155:1)
    at ReplManager.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/repl.js:129:1)
    at bound (domain.js:426:14)
    at REPLServer.runBound [as eval] (domain.js:439:12)
    at REPLServer.onLine (repl.js:760:10)
    at REPLServer.emit (events.js:315:20)
    at REPLServer.EventEmitter.emit (domain.js:482:12)
    at REPLServer.Interface._onLine (readline.js:329:10)
    at REPLServer.Interface._line (readline.js:658:8)
    at REPLServer.Interface._ttyWrite (readline.js:999:14)
    at REPLServer.self._ttyWrite (repl.js:851:9)
    at ReadStream.onkeypress (readline.js:205:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:482:12)
    at emitKeys (internal/readline/utils.js:335:14)
    at emitKeys.next (<anonymous>)

The reason seemed to be a naming conflict (but it's not. well... it is but... see below). But as a side-question: Openzeppelin and chainlink both include a SafeMath contract:

Compiling your contracts...
> ...
> Compiling @chainlink/contracts/src/v0.6/vendor/SafeMath.sol
> ...
> Compiling @openzeppelin/contracts/math/SafeMath.sol

> Duplicate contract names found for SafeMath.
> This can cause errors and unknown behavior. Please rename one of your contracts.

How can I use both chainlink and openzeppelin withouth running into this issue. Is this only possible with two completely separate contracts that only communicate through transactions? Or what do I not get here?


So... the actual problem seems to be just chainlink and/or truffle.

While the question remains, how to resolve those naming conflicts, I realized that the Buffer.isBuffer issue has nothing to do with it but with chainlink/truffle itself it seems.

If I import for example something from openzeppelin, like Ownable, everything works fine. But if I import chainlink and inherit from ChainlinkClient, the truffle console crashes with above exception once I first compiled the contract.

I recorded this, see here: https://youtu.be/InNPguD3h6g

It turns out the native node object, Buffer, is being overwritten when you have a contract with this name. In general contract names can conflict with native node objects.

Related issue on GitHub: https://github.com/trufflesuite/truffle/issues/3329

My project: https://github.com/mktcode/mergepay-contracts

  • I tried the same versions on Ubuntu 20.04 with metacoin example and it works as expected. I'd guess something is wrong in your setup try using nvm to install a separate instance of node, check is some of the project dependencies has a conflict with truffle. Also you should report your issue with truffle developers at github.com/trufflesuite/truffle.
    – Ismael
    Commented Aug 30, 2020 at 3:22
  • 1
    @Ismael I'll do that now. I asked in their Gitter chat first but didn't get an answer yet. Commented Aug 30, 2020 at 9:35
  • Have you tried importing it into remix? Doing this might provide more information.
    – T. Thomas
    Commented Sep 2, 2020 at 3:43
  • @T.Thomas The issue is resolved. Well, at least it's known what needs to be fixed. Commented Sep 2, 2020 at 13:59

1 Answer 1


Currently when using the Truffle console, it loads in all your contract names as a convenience so that you can access your deployed contracts etc. This, however, causes an issue when there are contract names that conflict with Node native objects; in this case the native Buffer object. It would be kind of like if you had a contract named "String". This would overwrite the native String object and it would become inaccessible.

So hopefully this is something that Truffle can fix, perhaps by providing a namespace for contract names that clash with names that already exist in that context.

Your Answer

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

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