POOLS Chain Documentation
  • Introduction
    • Version
    • Purpose: Blockchain & AI
    • Mission
    • Vision
  • MARKET OVERVIEW
    • Blockchain Market: Current State
    • Blockchain Market: Issues
    • Pools Chain Solutions
  • POOLS CHAIN OVERVIEW
    • Pools chain: Definition & Main functions
    • Features and Utilities
    • Compatible with EVM
    • Abilibitiy of Extension
    • Interoperable
    • Artificial Intelligence
    • Ecosystem
    • Dapps
      • Pools Wallet
      • AIHomes
      • Friendify GPT
      • More Dapps
      • Pools Phone
        • Pools Phone System
        • Pools Phone Authentication
  • Startmobis
  • TECHNICAL ARCHITECTURE
    • Proof-of-Stake (PoS)
    • Node structure
    • Security & Encryption mechanisms
    • Security and Finality
    • Reward
    • Validator Quorum
    • Staking and Governance
    • Staking on POOLS
    • Rewarding
    • Slashing
    • Double Sign
    • Governance Parameters
    • Smart contract language
      • Hardhat: Deploy ERC20 Contract
      • Truffle: Deploy ERC20 Contract
  • Develop smart contracts
  • Integrated smart contracts
  • Smart Contract Verification
    • Overview
    • How to verify your smart contracts on Pools Chain
  • Smart contract
    • Smart Contract Language
      • Hardhat
      • Truffle
    • Smart Contract Development
    • Smart Contract A.I Integration
    • Smart Contract Verification
      • Overview
      • How to verify your smart contracts on Pools Chain
  • TOKENOMIC
    • POOLS Coin: Role & Use case
    • Coin Distribution
    • Incentive Structure
  • ROADMAP & DEVELOPMENT PLAN
    • Pools Chain: Development Milestone
      • A playground for developers
      • Build the Infrastructure
      • Partnership
      • Marketing & PR
    • Future Plans
  • TEAM & PARTNERS
    • Core Team
    • Advisor & Partnership
  • NOTICE & DISCLAIMER
    • Legal Notices & Warnings
    • Regulatory Compliance & Transparency
    • Responsibilities & Rights
      • Pools Chain
      • Users
  • BUILT FOR DEVELOPERS
    • Pools SDK
      • Supported platforms
        • JavaScript
          • React
          • Pure JavaScript
          • Other web frameworks
          • React Native
          • Node.js
          • Electron
        • Mobile
          • Native IOS
    • Contract deploy
    • Blockchain Explorer
  • CONTACT US
    • Summary
    • Contact for further info
Powered by GitBook
On this page
  • Install the SDK​
  • Use the SDK​
  1. BUILT FOR DEVELOPERS
  2. Pools SDK
  3. Supported platforms
  4. JavaScript

React Native

You can import Pools SDK into your React Native dapp to enable your users to easily connect to the Pools Wallet

Install the SDK​

Use rn-nodeify to install the SDK. In your project directory, install rn-nodeify:

yarn add --dev rn-nodeify

or

npm i --dev rn-nodeify

Install the rn-nodeify libraries:

yarn add react-native-crypto
yarn add react-native-randombytes
yarn add crypto
yarn add process
yarn add stream
yarn add events

In your project's package.json file, insert the rn-nodeify command into the postinstall script:

package.json

"scripts": {
  ...,
  "postinstall": "rn-nodeify --install 'crypto,process,stream,events' --hack"
}

rn-nodeify creates a shim.js file in your project root directory. Import it in the root file of your application:

import './shim'

Install react-native-background-timer:

yarn add react-native-background-timer

cd ios && pod install && cd ..

Install Pools SDK:

yarn add @pools/sdk

Run the postinstall script after everything is installed:

yarn postinstall

Finally, install the necessary pods that come with the libraries:

cd ios && pod install && cd ..

Use the SDK​

Import, instantiate, and use the SDK by adding something similar to the following to your project script:

import PoolsSDK from '@pools/sdk';
import { Linking } from 'react-native';
import BackgroundTimer from 'react-native-background-timer';

const PSDK = new PoolsSDK({
  openDeeplink: (link) => {
    Linking.openURL(link); // Use React Native Linking method or another way of opening deeplinks.
  },
  timer: BackgroundTimer, // To keep the dapp alive once it goes to background.
  dappMetadata: {
    name: 'My dapp', // The name of your dapp.
    url: 'https://mydapp.com', // The URL of your website.
  },
});

const ethereum = PSDK.getProvider();

const accounts = await ethereum.request({ method: 'eth_requestAccounts' });

You can configure the SDK using any options and call any provider API methods. Always call eth_requestAccounts using ethereum.request(args) first, since it prompts the installation or connection popup to appear.

You can use EthersJS with your React Native app:

const provider = new ethers.providers.Web3Provider(ethereum);

// Get the balance of an account (by address or ENS name, if supported by network).
const balance = await provider.getBalance(ethereum.selectedAddress);

// Often you need to format the output to something more user-friendly,
// such as in ether (instead of wei).
const balanceInETH = ethers.utils.formatEther(balance);
// '0.182826475815887608'

Edit this page

PreviousOther web frameworksNextNode.js

Last updated 1 year ago