All Projects → truffle-box → drizzle-react-native-box

truffle-box / drizzle-react-native-box

Licence: other
This box is to help get you started with building dapps with Drizzle on React Native.

Programming Languages

javascript
184084 projects - #8 most used programming language
objective c
16641 projects - #2 most used programming language
Starlark
911 projects
java
68154 projects - #9 most used programming language
solidity
1140 projects

Projects that are alternatives of or similar to drizzle-react-native-box

resources
A living collection of resources for participants (and anyone who's interested) in Truffle University's courses 📚
Stars: ✭ 27 (+58.82%)
Mutual labels:  drizzle

⚠️ This box is deprecated. It is likely some features in this box will not work as expected. ⚠️

Drizzle React Native Box

This box will get you up and running with building a dapp on React Native (Android and iOS).

Installation

  1. Install Truffle and Ganache CLI globally

    npm install -g truffle
    npm install -g ganache-cli
    
  2. Download the box. This also takes care of installing the necessary dependencies.

    truffle unbox drizzle-react-native
  3. Go through the React Native tutorial. Make sure to select Building Projects with Native Code since we will be leveraging some native code.

Connecting your app to your Ganache testnet

When we're Working with React Native and mobile apps, accessing the Ganache server that's running on your machine takes a bit more work than when we are building web apps. The sections below detail how to connect to the Ganache testnet with your mobile device/emulator.

Running the app

  1. Start React Native Metro bundler: react-native start
  2. Start your emulator/plug in your device

Android (Emulator/Physical Device)

The main thing for Android devices is that we have to reverse the ports so that we can point to localhost on the Android device to the Ganache server.

Make sure you've setup the Android Debug Bridge (adb) before doing these steps.

  1. Start ganache-cli: ganache-cli -b 3
  2. Compile and migrate contracts: truffle compile && truffle migrate
  3. Reverse ports: adb reverse tcp:8545 tcp:8545
  4. Install app: react-native run-android

iOS

Simulator

The iOS simulator will see servers on localhost just fine.

  1. Start ganache-cli: ganache-cli -b 3
  2. Compile and migrate contracts: truffle compile && truffle migrate
  3. Install app: react-native run-ios (you can also do this through Xcode)

Physical device

iOS physical devices involve the most manual work relative to other devices. You have to look up the local IP address of your machine and manually handle it every time it changes.

  1. Find your LOCAL_MACHINE_IP by checking your network settings on your Mac where Ganache is running
  2. Start ganache-cli: ganache-cli -b 3 -h LOCAL_MACHINE_IP
  3. In truffle.js for development, point Truffle to LOCAL_MACHINE_IP
  4. Compile and migrate contracts: truffle compile && truffle migrate
  5. In index.js, point Drizzle to LOCAL_MACHINE_IP
    const options = {
      ...
      web3: {
        fallback: {
          type: "ws",
          url: "ws://LOCAL_MACHINE_IP:8545"
        }
      }
    };
  6. Install: Do it through Xcode
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].