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

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
主站蜘蛛池模板: 突泉县| 吴江市| 射洪县| 方正县| 常宁市| 江油市| 黔西县| 华亭县| 廉江市| 大悟县| 大石桥市| 山阳县| 孙吴县| 汝阳县| 鞍山市| 修文县| 黄骅市| 卢氏县| 德清县| 辽中县| 新丰县| 高清| 广南县| 红桥区| 定远县| 康保县| 福建省| 扶绥县| 阿拉善右旗| 昌邑市| 成都市| 万全县| 澄城县| 永登县| 奉节县| 屯昌县| 东乌珠穆沁旗| 邹平县| 惠安县| 抚远县| 杭锦旗|