Installation on React with Truffle Box in Blockchain
Truffle Framework & React

Installation on React with Truffle Box in Blockchain

React Truffle Box

This box comes with everything you need to start using smart contracts from a react app. This is as barebones as it gets, so nothing stands in your way.

Installation

First ensure you are in a new and empty directory.

1. Install Truffle globally in client machines

npm install -g truffle        

2. Unbox truffle boilerplate templates that we are working with react js apps. A Create-React-App is generated in the?client?directory.

truffle unbox react
        

3. Run the development console.

truffle develop        

4. Compile and migrate the smart contracts. Note inside the development console we don't preface commands with?truffle.

compile
migrate        

5. In the?client?directory, we run the React app. Smart contract changes must be manually recompiled and migrated.

cd client
npm run start        

6. Truffle can run tests written in Solidity or JavaScript against your smart contracts. Note the command varies slightly if you're in or outside of the development console.

// inside the development console.
test

// outside the development console..
truffle test        

7. Jest is included for testing React components. Compile your contracts before running Jest, or you may receive some file not found errors.

// ensure you are inside the client directory when running this
npm run test        

8. To build the application for production, use the build script. A production build will be in the?client/build?folder.

// ensure you are inside the client directory when running this
npm run build        

More details- https://github.com/truffle-box/react-box

Key Takeaways

truffle compile
truffle migrate
truffle test
truffle migrate --reset
cd client 
npm test
npm run start
npm run build
truffle development
truffle develop
truffle build
truffle --quiet
stop truffle develop command- Ctr+D
        


要查看或添加评论,请登录

MD. SHOHAG MIA的更多文章

  • Differences between AddTransient, AddScoped and AddSingleton Services in ASP.NET Core

    Differences between AddTransient, AddScoped and AddSingleton Services in ASP.NET Core

    Transient ASP.NET Core will create and share an instance of the service every time to the application when we ask for…

    2 条评论
  • Public Vs Private Blockchain

    Public Vs Private Blockchain

    Public Blockchain 1) Prime Features - Fully Decentralized Network, Permissionless, High Data Security. 2) Consensus…

    1 条评论
  • Encapsulation- SOLIDITY

    Encapsulation- SOLIDITY

    Encapsulation is one of the most important pillars of OOP. Encapsulation refers to the process of hiding or allowing…

  • Abstract Contracts- SOLIDITY

    Abstract Contracts- SOLIDITY

    Contracts in Solidity are same as classes in object-oriented languages. Contracts are identified as abstract contracts…

  • Polymorphism- SOLIDITY

    Polymorphism- SOLIDITY

    Polymorphism is an ability to process data in more than one form as like others OOP Programing. There are two types of…

    1 条评论
  • Introduction to Merkle Tree or Binary Merkle Tree in Blockchain

    Introduction to Merkle Tree or Binary Merkle Tree in Blockchain

    A Merkle tree is a data structure that is used for secure verification of data in a large content pool. It's also…

  • Solidity Programing

    Solidity Programing

    Solidity is a high-level and contract-oriented language used for writing smart contracts. It is used for designing and…

社区洞察

其他会员也浏览了