Truffle frame of use __ block chain

Source: Internet
Author: User

The environment version is as follows MAC environment: input truffle The version check truffle environment, this article is v3.4.5


1.

Create a new demo root directory, enter this directory at the command line, enter truffle init webpack (creating a Web application), and the Truffle init command will now not generate an upper-level Web page instance. The directory is as follows




App folder contains front-end interface (show to user) and JS file (interact with smart contract)

Contracts folder to store your only contract files, such as the above figure he generated a use case intelligent contract metacoin, in the future when you deploy your own smart contract can be deleted, the only contract to put their own here.

Node_modules folders are dependent on the environment.

The test folder is where you store some of the testing files.

2. Generated file directory There is a readme under the app that operates according to the Readme

Compile project truffle compile run as follows


3. Start TESTRPC,TESTRPC The default startup is to give you 10 accounts, each with 100ether inside. Input TESTRPC

For local testing, startup Testrpc will print out the account and private key for the test, which will be used during the subsequent test.

The results are as follows

4. Release operation, open a new terminal

CD to the file directory and then execute: truffle migrate after adding or deleting a contract, you can perform the truffle migrate--reset command to redeploy the contract. The results are as follows:

5. Start service: NPM run dev results are as follows:


6.

Access: As of this step, the end of the test, the server to start the completion. Interested students may find that after the service is started, another test terminal already has content printed. Open the browser and enter http://localhost:8080

The results are as follows:


This is truffle for you automatically generated a block-chain based Web application sample, in the Testrpc to find an account can operate the Metacoin transfer sample.

As shown in the figure, the default account has 10,000 meta. The address of this account is the No. 0 of the account address that executes TESTPRC print out.

transfer Operation

Enter 111 in the Amount input box;
To enter an account other than the No. 0 account (TESTRPC terminal print account), click Send Metacoin to see the results.

Transaction completed, current account amount changed to 9,889 meta

Above is how the truffle framework is used and you want to know more
you can refer to the official address of the project: Https://github.com/ConsenSys/truffle
Help document address: http:// truffle.readthedocs.io/en/latest/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.