一、http://nodejs.cn/下载并安装v8.11.1版本。

可设置npm国内源的命令: sudo npm config set registry http://registry.npm.taobao.org。

二、使用命令 sudo npm install -g truffle 安装(Truffle v4.1.7 - a development framework for Ethereum)。

三、进入项目目录cd /Users/shijun/Desktop/truffleWorkspace/metacoin,使用命令truffle unbox metacoin创建自带demo的工程。(truffle init可创建空工程)

工程结构包括:

1、contracts目录是Solidity合约代码,Migrations.sol必须,其他是自己编写的合约代码。

2、migrations目录是合约部署脚本,1_initial_migration.js是部署Migrations.sol的,其他的脚本按顺序依次执行。

3、test目录是测试代码。

四、进入ganache的下载地址https://github.com/trufflesuite/ganache/releases,下载并安装Ganache-1.1.0.dmg版本,图形界面形式。(也可以sudo npm install -g ganache-cli命令方式安装)。

五、修改工程中的truffle.js文件,部署到区块链网络。

module.exports = {  
    networks: {  
        development: {  
            host: 'localhost',  
            port: '7545',  
            network_id: '*' // Match any network id  
        }  
    }  
};  

依次执行truffle命令:

1、truffle compile  

2、truffle migrate 

3、truffle test

截图如下:

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

mac智能合约metacoin一条龙步骤(nodejs、truffle、atom、ganache)

转载于:https://my.oschina.net/duojin/blog/1800681

相关文章:

  • 2021-08-28
  • 2021-08-02
  • 2021-04-19
  • 2021-08-26
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
猜你喜欢
  • 2021-05-30
  • 2021-05-14
  • 2021-04-21
  • 2021-12-18
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案