trufflesuite / ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
https://www.trufflesuite.com/ganache
MIT License
3.36k stars 695 forks source link

How to listen to existing Ganache instance in another Terminal tab or window? #803

Closed remote-gildor closed 3 years ago

remote-gildor commented 3 years ago

Let's say I run ganache-cli in a terminal tab. Is it possible to listen to the same Ganache instance in another terminal tab or window (and see all the logs)? If yes, how?

davidmurdoch commented 3 years ago

Might be possible on some platforms. Examples can be found on https://askubuntu.com/questions/703516/execute-command-in-one-terminal-and-get-the-output-in-another-terminal-it-it-pos

What is your use case here?

remote-gildor commented 3 years ago

Hi @davidmurdoch , my usecase is that I start Ganache with JavaScript code (like this), but then I don't see transaction logs in the Terminal whenever I make an ETH transaction.

davidmurdoch commented 3 years ago

Ah, you just need to add logger: console, to your ganache.server options, like this:

const server = ganache.server({
  logger: console,
  port: PORT,
  fork: process.env.MAINNET_NODE_URL,
  network_id: 1,
  accounts: [
    {
      secretKey: process.env.PRIV_KEY_TEST,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
    {
      secretKey: process.env.PRIV_KEY_DEPLOY,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
  ],
});
remote-gildor commented 3 years ago

Nice! Thank you very much David! 🙂