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

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
主站蜘蛛池模板: 伽师县| 津市市| 太湖县| 凉山| 定安县| 连州市| 竹北市| 社旗县| 永登县| 深州市| 商城县| 罗田县| 凭祥市| 曲松县| 东乌| 宁安市| 龙泉市| 界首市| 定州市| 中西区| 抚远县| 利川市| 宿松县| 锦州市| 酒泉市| 关岭| 祥云县| 嘉祥县| 新河县| 垫江县| 崇义县| 黄骅市| 渝中区| 安溪县| 马龙县| 高安市| 阳信县| 哈密市| 宁阳县| 桑日县| 汾西县|