Ganache 安装

一. 下载Ganache

Ganache下载链接

根据系统选择对应安装文件

Ganache 安装_第1张图片

 或者brew安装

brew install --cask ganache

二.打开app

点击quickstart

Ganache 安装_第2张图片

 Ganache 安装_第3张图片

 点击save按钮,保存workspace,此时已启动对应端口为7545

三.打开truffle项目,设置配置文件

我已初始化好truffle项目,可以看上篇文章truffle示例

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

部署合约项目

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

四.查看Ganache

回到Ganache,点击相关菜单可以看到合约已经部署到Ganache上

Ganache 安装_第4张图片

 Ganache 安装_第5张图片

 这里把配置文件添加进来Ganache 安装_第6张图片

 Ganache 安装_第7张图片

 由于部署之后添加的配置文件,这里并没有显示出刚刚部署的合约,再次部署一次,即可显示新部署的合约地址

你可能感兴趣的:(macos,Ganache)