Difference between Ganache and Truffle

Difference between Ganache and Truffle



What is the difference between this two? I understand that Ganache is like a fake blockchain, but Truffle has that too ?


fake



What are the limitations of each and under which circumstance we use either of them ?




3 Answers
3



Ganache allows you to create a private Ethereum blockchain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all actions you would on the main chain without the cost. Many developers use this to test their smart contracts during development. It provides convenient tools such as advanced mining controls and a built-in block explorer.



Truffle is a developer environment, testing framework and asset pipeline for blockchains. It allows developers to spin up smart contract project at the click of a button and provides you with a project structure, files, and directories that make deployment and testing much easier (or else you would have to configure these yourself).



under which circumstance we use either of them



As a developer, you would spin up a Truffle (truffle init) project that lays out the structure of your project. Once you start coding a little bit, you will want to test the code, but need a blockchain to do so. Now you run Ganache to be this blockchain. In your deployment file (a file that Truffle gives you when you create a project), you can point your project to either use Ganache or to use the main network. You can then run truffle migrate (which automatically runs truffle compile for you), to deploy the contracts with the data you provided in the migration files.


truffle init


truffle migrate


truffle compile



What are the limitations of each



Truffle isn't really limited in that all it is doing is providing a framework for you to sculpt a project in. The only "limitation" would simply be the features they may not have added yet.



Ganache is a little different, in that it is attempting to mimic the main network. There are a few problems here:



There are no miners on Ganache. Because of this, you cannot accurately mimic miner actions on the main network. As an example, say you wanted to send a transaction that filled almost all of the block. You can set the block height to 7M on Ganache and send a 6.9M transaction no problem. On the main network (depending on the current throughput), this transaction may or may not ever get mined.



The gasLimit on the main network is a moving target (it can be changed by miners. If, for some reason, you are depending on an exact number (as you can set in Ganache), you may find that you will run into issues.


gasLimit



Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. With Truffle, you get: Built-in smart contract compilation, linking, deployment and binary management.



Ganache is an ethereum client which one can use for Ethereum development.



Ganache is part of Truffle ecosystem. You can use ganache for the development of DAPP and once it is developed and tested on the ganache you can deploy your DAPP on ethereum client like geth or parity.



Truffle will enable you to develop, test and deploy your DAPP.



As you note, Truffle indeed bundles its own test blockchain; you can use the Ganache app with Truffle if you want (https://truffleframework.com/docs/truffle/quickstart#alternative-migrating-with-ganache), but it’s easier to use the built-in one, even easier than the existing QuickStart makes it seem. (See my suggested QuickerStart for how easy this is.) One gotcha, for debugging a test execution with the built-in blockchain: run truffle develop --log in a separate terminal session to get the relevant hashes you will need for debugging.


truffle develop --log



Thanks for contributing an answer to Ethereum Stack Exchange!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)