Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop the DAPP Application of ethernet Square by Truffle

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how Truffle develops DAPP applications in Ethernet Fang. the content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Basic environment

NodeJ 5.0 +

Python 3

Windows,Linux or Mac OS X

Install npm install truffle-g

Install truffle through the above instructions. The current version of truffle is 3.0, and you need to upgrade native python to python3. You can verify that the installation is successful through the truffle directive.

In the process of development, we usually install TestRpc as a test network, or we can choose not to install it and start the environment or truffle's develop environment through geth.

Npm install-g ethereumjs-testrpc

Similarly, we use testrpc to verify whether the installation is successful.

If there are all kinds of error reports during this period, please check whether the network can access various foreign websites such as github, and deal with the specific solution by yourself. if the installation of the python extension fails, please check the python version

Create a project mkdir democd demotruffle init

The initialized truffle directory structure generated by the above instruction

This is the simplest truffle project directory.

-contracts / / intelligent contract storage directory-migrations / / intelligent contract abi and deployment information storage directory-test / / test file-truffle.js / / truffle default configuration-truffle-config.js / / Windows default configuration file name conflicts with truffle, which can be resolved by using this file

So how do we generate a project with a user interface? in the old version of truffle, you can generate a project with a user interface directly through init, but it has been removed in the new version and can be created by installing the official webpack-based box.

Truffle unbox webpack

After the successful execution, let's compare the catalogs.

Start the project

First of all, we will start the network of Ethernet Fong in another environment, and the local network can be started through the testrpc command. The startup result is shown in the figure above. We verify the successful installation of testrpc. Let's start another Terminal and enter the project directory.

Truffle compile / / compile Smart contract truffle migrate / / deploy Smart contract using truffle deploy in truffle2

Before we start the project, we need to install another plug-in web3, everyone, there is a very bad point, web3 requires the version of python to be python2, you can install web3 before installing truffle.

Npm install-g web3

After the installation is complete, we can start the project. Before that, we need to modify the truffle.js file in the root directory of the project and change the port in it to 8545, that is, the port where testrpc listens.

Npm run dev

At this point, the whole project was launched successfully. Before we visit the project, we need to install an extension MetaMask in the chrome browser and then open MetaMask to create an account. We need to switch the network to the local environment and import the account provided by testrpc.

Then switch the account to the account we just imported, and then we can access localhost:8080

If you see this interface, it means that your project is running normally, and then you can wave as much as you like.

This is the end of how Truffle develops DAPP applications in Ethernet Square. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report