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

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
主站蜘蛛池模板: 聂拉木县| 丰镇市| 兴安盟| 澄江县| 丰宁| 万源市| 宁海县| 商南县| 涟水县| 莫力| 宜都市| 北京市| 武胜县| 隆化县| 休宁县| 江北区| 岳池县| 乌兰县| 富顺县| 万盛区| 赣州市| 石阡县| 淮滨县| 洪湖市| 霍城县| 大同县| 宁夏| 边坝县| 印江| 汉寿县| 凭祥市| 梧州市| 庆安县| 巴林左旗| 鸡西市| 金川县| 聂荣县| 子长县| 西华县| 溧阳市| 天峻县|