Ganache installation

1. Download Ganache

Ganache download link

Select the corresponding installation file according to the system

 or brew install

brew install --cask ganache

2. Open the app

click quickstart

 

 Click the save button to save the workspace. At this time, the corresponding port is 7545

3. Open the truffle project and set the configuration file

I have initialized the truffle project, you can see the truffle example in the previous article

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    }
  }
};

Deploy contract project

truffle migrate

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


Starting migrations...
======================
> Network name:    'development'
> Network id:      5777
> Block gas limit: 6721975 (0x6691b7)


1_deploy_contracts.js
=====================

   Replacing 'ConvertLib'
   ----------------------
   > transaction hash:    0xceec810a729c44a17f539fbd3fde2d6bbbb7f827f2ff136d5bd3aca8279fbfe4
   > Blocks: 0            Seconds: 0
   > contract address:    0xa5bd15882E625B4EA7D878553D2Cf3C30B0a44dF
   > block number:        1
   > block timestamp:     1680192418
   > account:             0xEb110D13835ff1e9B65320682601634D041dD505
   > balance:             99.999468208
   > gas used:            157568 (0x26780)
   > gas price:           3.375 gwei
   > value sent:          0 ETH
   > total cost:          0.000531792 ETH


   Linking
   -------
   * Contract: MetaCoin <--> Library: ConvertLib (at address: 0xa5bd15882E625B4EA7D878553D2Cf3C30B0a44dF)

   Replacing 'MetaCoin'
   --------------------
   > transaction hash:    0x6c4a8b8825f8224a3c57e36d2f3ce62a3e38821927c6c334679961f87cce3e94
   > Blocks: 0            Seconds: 0
   > contract address:    0x25Fc626Ec4674bfa163CD26d9E7bcC50e3E0f586
   > block number:        2
   > block timestamp:     1680192418
   > account:             0xEb110D13835ff1e9B65320682601634D041dD505
   > balance:             99.998105632065943366
   > gas used:            416594 (0x65b52)
   > gas price:           3.270752661 gwei
   > value sent:          0 ETH
   > total cost:          0.001362575934056634 ETH

   > Saving artifacts
   -------------------------------------
   > Total cost:     0.001894367934056634 ETH

Summary
=======
> Total deployments:   2
> Final cost:          0.001894367934056634 ETH

4. View Ganache

Go back to Ganache, click on the relevant menu to see that the contract has been deployed on Ganache

 

 Add the configuration file here

 

 Due to the configuration file added after deployment, the newly deployed contract is not displayed here, and the newly deployed contract address can be displayed by deploying it again

Guess you like

Origin blog.csdn.net/chen_peng7/article/details/129869401