Ganache |
Truffle |
allows you to create a private Ethereum block chain 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. |
a developer environment, testing framework and asset pipeline for block
chains. It allows developers to spin up a 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). |
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. |
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. |
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.
Source: https://ethereum.stackexchange.com/questions/58093/difference-between-ganache-and-truffle
Nhận xét