官术网_书友最值得收藏!

Installing Truffle and Solidity

Truffle is a development framework for developing a smart contract with Solidity. You can create one without Truffle, but Truffle makes it easier. Without Truffle, you can still write a smart contract, but to compile it, you have to launch the Solidity compiler with certain flags. Then, in order to deploy this smart contract to the blockchain, you have to create a script to send the bytecode to the blockchain. With Truffle, in order to compile, you call the, truffle compile command, and to deploy a smart contract to the blockchain, you call the truffle migrate command after writing a simple migration script. Truffle also provides you with a tool for interacting with the smart contract in the blockchain network. It has everything you need to develop a smart contract. As stated previously, however, we will not be using this framework in the next chapter.

We are going to start by installing Truffle using the Node.js package manager. In Ubuntu Linux, in order to install Truffle globally, we have to use sudo. As described in the previous paragraph, Truffle is a smart contract development framework containing many tools, including a console application to interact with the blockchain network and the development blockchain software. On top of that, with Truffle, you get the Solidity compiler as well.

But first, you need to make sure npm installs software globally in your home directory:

$ mkdir ~/.npm-global
$ npm config set prefix '~/.npm-global'

Then append this line to the ~/. profile file:

export PATH=~/.npm-global/bin:$PATH

Now, open a new Terminal so that the new profile file takes effect or, alternatively, do the following:

$ source ~/.profile

Then, we can install Truffle as follows:

$ npm install -g truffle
$ truffle version
Truffle v5.0.2 (core: 5.0.2)

Solidity v0.5.0 (solc-js)
Node v10.15.0
主站蜘蛛池模板: 兴国县| 都江堰市| 福建省| 永春县| 安平县| 天等县| 赤城县| 平阳县| 鹤山市| 娱乐| 兴城市| 瑞昌市| 稻城县| 施秉县| 防城港市| 曲靖市| 黎平县| 安顺市| 中西区| 宜兰县| 格尔木市| 吴堡县| 徐闻县| 芮城县| 中卫市| 红安县| 哈尔滨市| 泰兴市| 曲周县| 阿拉善盟| 山东| 龙川县| 林州市| 景谷| 喜德县| 体育| 武鸣县| 新民市| 水城县| 库伦旗| 类乌齐县|