Ruthie  Blanda

Ruthie Blanda

1660319880

Ethkit: Cross Chain Dapp Starter Kit (ETH / Moralis) On React

ethkit (Cross chain support via Moralis)

NOTE: TypeScript version of this repo is WIP

React components and hooks for fast building dApps without running own backend

๐Ÿš€DEMO: https://ethereum-boilerplate.github.io/ethereum-boilerplate

This boilerplate is built on react-moralis and Moralis. Also has its own context provider for quick access to chainId or ethAddress

There are many components in this boilerplate that do not require an active web3 provider, they use Moralis Web3 API. Moralis supports the most popular blockchains and their test networks. You can find a list of all available networks in Moralis Supported Chains

Please check the official documentation of Moralis for all the functionalities of Moralis.

daPPdemo

โญ๏ธ Star us

If this boilerplate helps you build Ethereum dapps faster - please star this project, every star makes us very happy!

๐Ÿค Need help?

If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this boilerplate is the super active community ready to help at any time! We help each other.

๐Ÿš€ Quick Start

๐Ÿ“„ Clone or fork ethereum-boilerplate:

git clone https://github.com/ethereum-boilerplate/ethereum-boilerplate.git

๐Ÿ’ฟ Install all dependencies:

cd ethereum-boilerplate
yarn install

โœ Rename .env.example to .env in the main folder and provide your appId and serverUrl from Moralis (How to start Moralis Server) Example:

REACT_APP_MORALIS_APPLICATION_ID = xxxxxxxxxxxx
REACT_APP_MORALIS_SERVER_URL = https://xxxxxx.grandmoralis.com:2053/server

๐Ÿšดโ€โ™‚๏ธ Run your App:

yarn start

๐Ÿงญ Table of contents

๐Ÿ— Ethereum Components

๐Ÿ›  The ready for use react-components are located in src/components. They are designed to be used anywhere in your dApp.

โšก Note that many components may get params like chain, address, size and etc.

<Account />

Account

๐Ÿ“’ <Account /> : Easy web3 authentication via MetaMask.

<Account />

<Address />

address

๐Ÿ“จ <Address /> : Displays an Ethereum address with Blockie avatar.

Options:

  • copyable (optional): display icon for copying.
  • avatar (optional): display blockie avatar.
  • size (optional): text size.
<Address />
<Address avatar />
<Address avatar copyable />
<Address avatar copyable size="4"  />

<AddressInput />

input

๐Ÿ“ซ <AddressInput /> : Input for eth address. Displays Blockie avatar for the entered wallet. Helps to validate addresses. After entering 42 characters (0x... wallet length) or valid crypto domain freezes input and calls setValidatedAddress. Supported domains: [".eth", ".crypto", ".coin", ".wallet", ".bitcoin", ".x", ".888", ".nft", ".dao", ".blockchain"]

Options:

  • autoFocus (optional): focuses object after rendering the component.
  • placeholder (optional): text to display before entering address.
  • onChange (required): your setState hook.
const [address, setAddress] = useState();

<AddressInput
  autoFocus
  placeholder="Input your Address"
  onChange={setAddress}
/>;

<Chains />

network

โ›“ <Chains /> : Active network switch. Supports Ethereum, Polygon, BSC and Avalacnhe blockchains. Works only with networks that have already been added to Injected Wallet. You can find a guide on how to programmatically add a new network here. Easily customizable, you can add other networks

Options:

  • props (optional): networks to display. Added by default: polygon, eth, bsc and avalanche
<Chains polygon eth bsc avalanche />

<CoinPrice />

price

๐Ÿ’ต <CoinPrice /> : displays the price of the token specified in the settings. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • address (required): Token contract address
  • chain (optional): The network to which the token is deployed. Default: ETH
  • image (optional): local path or link to token logo
  • size (optional): logo size
<CoinPrice address="0x1...3" chain="eth" image="https://img.png" size="40px" />

<ERC20Balance />

image

๐Ÿ’ฐ <ERC20Balance /> : displays the ERC20 balance of an address. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): network for displaying balances on. Will use your wallet network if you do not specify chain yourself
<ERC20Balance chain="polygon" />

<ERC20Transfers />

image

๐Ÿ’ธ <ERC20Transfers /> : displays the ERC20 transfers of an address. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): network for displaying transfers on. Will use your wallet network if you do not specify chain yourself
<ERC20Transfers chain="polygon" />

<DEX />

dex

๐Ÿ’ฑ <DEX /> : interface for Moralis 1Inch Plugin. This plugin integrates the DeFi / DEX aggregator 1Inch to any project that uses Moralis.

Options:

  • chain (optional): network. Available: Ethereum (โ€œethโ€), Binance Smart Chain (โ€œbscโ€), Polygon (โ€œpolygonโ€)
  • customTokens (optional): object with custom tokens. You can see the example below.
<DEX chain="eth" />
// Adding custom tokens

const customTokens = {
  "0x2180F5cC1ddf117640963AE91868948bd3EF6838": {
    address: "0x2180F5cC1ddf117640963AE91868948bd3EF6838",
    decimals: 9,
    logoURI:
      "https://assets.coingecko.com/coins/images/20985/small/_VoQPDDs_400x400.jpg?1638168643",
    name: "AscensionArcade",
    symbol: "AAT",
  },
};

<DEX chain="eth" customTokens={customTokens} />;

<Wallet />

wallet

๐Ÿ’ผ <Wallet /> : example interface for interacting with your wallet. Uses components from the boilerplate: <Blockie />, <Address />, <NativeBalance />, <AddressInput />. Has the functionality to send tokens

<Wallet />

<Blockie />

<NativeBalance />

<NFTBalance />

<Contract />

๐Ÿงฐ Ethereum Hooks

useAPIContract()

๐Ÿ“‹ Runs a given function of a contract abi and returns readonly data. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • functionName (required): The function name
  • address (required): A smart contract address
  • abi (required): contract or function ABI(should be provided as an array)
  • params (optional): Parameters needed for your specific function

Example:

import { useAPIContract } from "react-moralis"

const ShowUniswapObserveValues = () => {
  const { runContractFunction, data, error, isLoading, isFetching } = useAPIContract({
    abi: usdcEthPoolAbi,
    address: usdcEthPoolAddress,
    functionName: "observe",
    params: {
      secondsAgos: [0, 10],
    },
  });

  return (<div>
    {error && <ErrorMessage error={error} />}
    <button onClick={() => runContractFunction()} disabled={isLoading}>Fetch data</button>
    {contractResponse && JSON.stringify(contractResponse)}
    </pre>}
  </div>)
}

useWeb3Contract()

๐Ÿ“‹ Runs on-chain functions. Requires active Web3 Provider.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • functionName (required): The function name
  • contractAddress (required): A smart contract address
  • abi (required): contract or function ABI(should be provided as an array)
  • params (optional): Parameters needed for your specific function

Example:

import { useWeb3Contract } from "react-moralis"

const ShowUniswapObserveValues = () => {
  const { runContractFunction, contractResponse, error, isRunning, isLoading } = useWeb3Contract({
    abi: usdcEthPoolAbi,
    contractAddress: usdcEthPoolAddress,
    functionName: "observe",
    params: {
      secondsAgos: [0, 10],
    },
  });

  return (<div>
    {error && <ErrorMessage error={error} />}
    <button onClick={() => runContractFunction()} disabled={isLoading}>Fetch data</button>
    {contractResponse && JSON.stringify(contractResponse)}
    </pre>}
  </div>)
}

useERC20Balances()

๐Ÿ’ฐ Gets all token balances of a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • to_block (optional): The block number on which the balances should be checked

Example

import { useERC20Balances } from "react-moralis";

const { fetchERC20Balances, data, isLoading, isFetching, error } =
  useERC20Balances();

const ERC20Balances = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetchERC20Balances({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
      "name": "Kylin Network",
      "symbol": "KYL",
      "logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
      "thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
      "decimals": "18",
      "balance": "123456789"
    }
  ]
}

useERC20Transfers()

๐Ÿงพ Gets ERC20 token transfers of a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • offset (optional): Offset.
  • limit (optional): Limit.

Example

import { useERC20Transfers } from "react-moralis";

const { fetchERC20Transfers, data, error, isLoading, isFetching } =
  useERC20Transfers();

const ERC20Transfers = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetchERC20Transfers({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
      "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "block_timestamp": "2021-04-02T10:07:54.000Z",
      "block_number": "12526958",
      "block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86",
      "to_address": "0x62AED87d21Ad0F3cdE4D147Fdcc9245401Af0044",
      "from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
      "value": "650000000000000000"
    }
  ]
}

useNativeBalance()

๐Ÿ’ฐ Gets native balance for a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • to_block (optional): The block number on which the balances should be checked

Example:

import { useNativeBalance } from "react-moralis";

function NativeBalance() {
  const {
    getBalance,
    data: balance,
    nativeToken,
    error,
    isLoading,
  } = useNativeBalance({ chain: "ropsten" });

  return <div>{balance.formatted}</div>;
}

Example return of balance (Object)

{
  balance: '996869309795359886',
  formatted: '0.9969 ROP'
}

Example return of nativeToken (Object)

{
  name: 'Ropsten Ether',
  symbol: 'ROP',
  decimals: 18
}

useNativeTransactions()

๐Ÿงพ Gets the transactions from the current user or specified address. Returns an object with the number of transactions and the array of native transactions

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • offset (optional): Offset.
  • limit (optional): Limit.

Example

import { useNativeTransactions } from "react-moralis";

const { getNativeTransations, data, chainId, error, isLoading, isFetching } =
  useNativeTransactions();

const NativeTransactions = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button
        onClick={() => getNativeTransations({ params: { chain: "0x1" } })}
      >
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "nonce": "326595425",
      "transaction_index": "25",
      "from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
      "to_address": "0xa71db868318f0a0bae9411347cd4a6fa23d8d4ef",
      "value": "650000000000000000",
      "gas": "6721975",
      "gas_price": "20000000000",
      "input": "string",
      "receipt_cumulative_gas_used": "1340925",
      "receipt_gas_used": "1340925",
      "receipt_contract_address": "0x1d6a4cf64b52f6c73f201839aded7379ce58059c",
      "receipt_root": "string",
      "receipt_status": "1",
      "block_timestamp": "2021-04-02T10:07:54.000Z",
      "block_number": "12526958",
      "block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86"
    }
  ]
}

useNFTBalances()

๐ŸŽจ Gets all NFTs from the current user or address. Supports both ERC721 and ERC1155. Returns an object with the number of NFT objects and the array of NFT objects.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.

Example

import { useNFTBalances } from "react-moralis";

const { getNFTBalances, data, error, isLoading, isFetching } = useNFTBalances();

const NFTBalances = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => getNFTBalances({ params: { chain: "0x1" } })}>
        Refetch NFTBalances
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "token_id": "15",
      "contract_type": "ERC721",
      "owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "block_number": "88256",
      "block_number_minted": "88256",
      "token_uri": "string",
      "metadata": "string",
      "synced_at": "string",
      "amount": "1",
      "name": "CryptoKitties",
      "symbol": "RARI"
    }
  ]
}

useNFTTransfers()

๐ŸŽจ Gets the NFT transfers. Returns an object with the number of NFT transfers and the array of NFT transfers.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • offset (optional): Offset.
  • direction (optional): The transfer direction. Available values : both, to, from . Default value : both.
  • format (optional): he format of the token id. Available values : decimal, hex. Default value : decimal.
  • limit (optional): Limit.

Example

import { useNFTTransfers } from "react-moralis";

const { fetch, data, error, isLoading, isFetching } = useNFTTransfers();

const NFTTransfers = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetch({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "token_id": "15",
      "from_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "to_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "amount": "1",
      "contract_type": "ERC721",
      "block_number": "88256",
      "block_timestamp": "2021-06-04T16:00:15",
      "block_hash": "string",
      "transaction_hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "transaction_type": "string",
      "transaction_index": "string",
      "log_index": 0
    }
  ]
}

useChain()

โ›“ Hook for fast network switching or getting info about current network. To change the current network, set the target chainId to switchNetwork function. If the user does not have the target network in the wallet, it will automatically ask permission to add it to the wallet.

Example:

import { useChain } from "react-moralis";

function Chains() {
  const { switchNetwork, chainId, chain, account } = useChain();
  return (
    <>
      <button onClick={() => switchNetwork("0x1")}>Switch to Ethereum</button>
      <p>Current chainId: {chainId}</p>
    </>
  );
}

useTokenPrice()

๐Ÿ’ฐ Gets the price nominated in the native token and usd for a given token contract address

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • exchange (optional): The factory name or address of the token exchange. Possible exchanges, for different chains are: ETH mainnet: uniswap-v3, sushiswap, uniswap-v2, BSC mainnet: pancakeswap-v2, pancakeswap-v1. Polygon mainnet: quickswap. If no exchange is specified, all exchanges are checked (in the order as listed above) until a valid pool has been found. Note that this request can take more time. So specifying the exchange will result in faster responses most of the time.
  • to_block (optional): Returns the price for a given blocknumber (historical price-data).

Example

import { useTokenPrice } from "react-moralis";

const TokenPrice = () => {
  const {
    fetchTokenPrice,
    data: formattedData,
    error,
    isLoading,
    isFetching,
  } = useTokenPrice({ address: "0x1f9840...1f984", chain: "eth" });

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button
        onClick={() =>
          fetchTokenPrice({ params: { address: "0x6...361", chain: "bsc" } })
        }
      >
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "exchangeAddress": "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  "exchangeName": "Uniswap v3",
  "formattedNative": "0.004695 ETH",
  "formattedUsd": "$20.38",
  "nativePrice": {
    "decimals": 18,
    "name": "Ether",
    "symbol": "ETH",
    "value": "4695118425598734"
  },
  "usdPrice": 20.37791922835578
}

DEX Hooks

useOneInchQuote()

๐Ÿ’ธ Hook for getting swap quote info.

Example:

import { useOneInchQuote } from "react-moralis";

function Quote() {
  const { getQuote, data, isFetching, isLoading, error } = useOneInchQuote({
    chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
    fromTokenAddress: "0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4", // The token you want to swap
    toTokenAddress: "0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4", // The token you want to receive
    amount: 1000,
  });
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
}

useOneInchQuote()

๐Ÿ’ธ Hook for swap.

Example:

import { useOneInchQuote } from "react-moralis";

function Swap() {
  const { swap, data, isFetching, isLoading, error } = useOneInchSwap();

  const options = {
    chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
    fromTokenAddress: "0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4", // The token you want to swap
    toTokenAddress: "0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4", // The token you want to receive
    amount: 1000,
    fromAddress: "0x6217e65d864d77DEcbFF0CFeFA13A93f7C1dD064", // Your wallet address
    slippage: 1,
  };

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => swap(options)}>Swap</button>
    </div>
  );
}

useOneInchTokens()

๐Ÿ’ธ Hook for get supported token list.

Example:

import { useOneInchQuote } from "react-moralis";

const SupportedTokens = () => {
  const { getSupportedTokens, data, isFetching, isLoading, error } =
    useOneInchTokens({ chain: "bsc" });

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Where to host your dApp?


Author: mairh
Source code: https://github.com/mairh/ethkit
License: MIT license
#react-native  #javascript 

What is GEEK

Buddha Community

Ethkit: Cross Chain Dapp Starter Kit (ETH / Moralis) On React
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Letโ€™s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The โ€œStack Overflow Developer Survey 2019โ€ report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? Itโ€™s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Franz  Becker

Franz Becker

1651604400

React Starter Kit: Build Web Apps with React, Relay and GraphQL.

React Starter Kit โ€” "isomorphic" web app boilerplate   

React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Express, GraphQL and React, containing modern web development tools such as Webpack, Babel and Browsersync. Helping you to stay productive following the best practices. A solid starting point for both professionals and newcomers to the industry.

See getting started guide, demo, docs, roadmap  |  Join #react-starter-kit chat room on Gitter  |  Visit our sponsors:

 

Hiring

Getting Started

Customization

The master branch of React Starter Kit doesn't include a Flux implementation or any other advanced integrations. Nevertheless, we have some integrations available to you in feature branches that you can use either as a reference or merge into your project:

You can see status of most reasonable merge combination as PRs labeled as TRACKING

If you think that any of these features should be on master, or vice versa, some features should removed from the master branch, please let us know. We love your feedback!

Comparison

 

React Starter Kit

React Static Boilerplate

ASP.NET Core Starter Kit

App typeIsomorphic (universal)Single-page applicationSingle-page application
Frontend
LanguageJavaScript (ES2015+, JSX)JavaScript (ES2015+, JSX)JavaScript (ES2015+, JSX)
LibrariesReact, History, Universal RouterReact, History, ReduxReact, History, Redux
RoutesImperative (functional)DeclarativeDeclarative, cross-stack
Backend
LanguageJavaScript (ES2015+, JSX)n/aC#, F#
LibrariesNode.js, Express, Sequelize,
GraphQL
n/aASP.NET Core, EF Core,
ASP.NET Identity
SSRYesn/an/a
Data APIGraphQLn/aWeb API

Backers

โ™ฅ React Starter Kit? Help us keep it alive by donating funds to cover project expenses via OpenCollective or Bountysource!

lehneres Tarkan Anlar Morten Olsen Adam David Ernst Zane Hitchcox  

How to Contribute

Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issue or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.

Learn More

Related Projects

  • GraphQL Starter Kit โ€” Boilerplate for building data APIs with Node.js, JavaScript (via Babel) and GraphQL
  • Membership Database โ€” SQL schema boilerplate for user accounts, profiles, roles, and auth claims
  • Babel Starter Kit โ€” Boilerplate for authoring JavaScript/React.js libraries

Support

License

Copyright ยฉ 2014-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.


Author: kriasoft
Source Code: https://github.com/kriasoft/react-starter-kit
License: MIT License

#graphql #react 

Ruthie  Blanda

Ruthie Blanda

1660319880

Ethkit: Cross Chain Dapp Starter Kit (ETH / Moralis) On React

ethkit (Cross chain support via Moralis)

NOTE: TypeScript version of this repo is WIP

React components and hooks for fast building dApps without running own backend

๐Ÿš€DEMO: https://ethereum-boilerplate.github.io/ethereum-boilerplate

This boilerplate is built on react-moralis and Moralis. Also has its own context provider for quick access to chainId or ethAddress

There are many components in this boilerplate that do not require an active web3 provider, they use Moralis Web3 API. Moralis supports the most popular blockchains and their test networks. You can find a list of all available networks in Moralis Supported Chains

Please check the official documentation of Moralis for all the functionalities of Moralis.

daPPdemo

โญ๏ธ Star us

If this boilerplate helps you build Ethereum dapps faster - please star this project, every star makes us very happy!

๐Ÿค Need help?

If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this boilerplate is the super active community ready to help at any time! We help each other.

๐Ÿš€ Quick Start

๐Ÿ“„ Clone or fork ethereum-boilerplate:

git clone https://github.com/ethereum-boilerplate/ethereum-boilerplate.git

๐Ÿ’ฟ Install all dependencies:

cd ethereum-boilerplate
yarn install

โœ Rename .env.example to .env in the main folder and provide your appId and serverUrl from Moralis (How to start Moralis Server) Example:

REACT_APP_MORALIS_APPLICATION_ID = xxxxxxxxxxxx
REACT_APP_MORALIS_SERVER_URL = https://xxxxxx.grandmoralis.com:2053/server

๐Ÿšดโ€โ™‚๏ธ Run your App:

yarn start

๐Ÿงญ Table of contents

๐Ÿ— Ethereum Components

๐Ÿ›  The ready for use react-components are located in src/components. They are designed to be used anywhere in your dApp.

โšก Note that many components may get params like chain, address, size and etc.

<Account />

Account

๐Ÿ“’ <Account /> : Easy web3 authentication via MetaMask.

<Account />

<Address />

address

๐Ÿ“จ <Address /> : Displays an Ethereum address with Blockie avatar.

Options:

  • copyable (optional): display icon for copying.
  • avatar (optional): display blockie avatar.
  • size (optional): text size.
<Address />
<Address avatar />
<Address avatar copyable />
<Address avatar copyable size="4"  />

<AddressInput />

input

๐Ÿ“ซ <AddressInput /> : Input for eth address. Displays Blockie avatar for the entered wallet. Helps to validate addresses. After entering 42 characters (0x... wallet length) or valid crypto domain freezes input and calls setValidatedAddress. Supported domains: [".eth", ".crypto", ".coin", ".wallet", ".bitcoin", ".x", ".888", ".nft", ".dao", ".blockchain"]

Options:

  • autoFocus (optional): focuses object after rendering the component.
  • placeholder (optional): text to display before entering address.
  • onChange (required): your setState hook.
const [address, setAddress] = useState();

<AddressInput
  autoFocus
  placeholder="Input your Address"
  onChange={setAddress}
/>;

<Chains />

network

โ›“ <Chains /> : Active network switch. Supports Ethereum, Polygon, BSC and Avalacnhe blockchains. Works only with networks that have already been added to Injected Wallet. You can find a guide on how to programmatically add a new network here. Easily customizable, you can add other networks

Options:

  • props (optional): networks to display. Added by default: polygon, eth, bsc and avalanche
<Chains polygon eth bsc avalanche />

<CoinPrice />

price

๐Ÿ’ต <CoinPrice /> : displays the price of the token specified in the settings. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • address (required): Token contract address
  • chain (optional): The network to which the token is deployed. Default: ETH
  • image (optional): local path or link to token logo
  • size (optional): logo size
<CoinPrice address="0x1...3" chain="eth" image="https://img.png" size="40px" />

<ERC20Balance />

image

๐Ÿ’ฐ <ERC20Balance /> : displays the ERC20 balance of an address. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): network for displaying balances on. Will use your wallet network if you do not specify chain yourself
<ERC20Balance chain="polygon" />

<ERC20Transfers />

image

๐Ÿ’ธ <ERC20Transfers /> : displays the ERC20 transfers of an address. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): network for displaying transfers on. Will use your wallet network if you do not specify chain yourself
<ERC20Transfers chain="polygon" />

<DEX />

dex

๐Ÿ’ฑ <DEX /> : interface for Moralis 1Inch Plugin. This plugin integrates the DeFi / DEX aggregator 1Inch to any project that uses Moralis.

Options:

  • chain (optional): network. Available: Ethereum (โ€œethโ€), Binance Smart Chain (โ€œbscโ€), Polygon (โ€œpolygonโ€)
  • customTokens (optional): object with custom tokens. You can see the example below.
<DEX chain="eth" />
// Adding custom tokens

const customTokens = {
  "0x2180F5cC1ddf117640963AE91868948bd3EF6838": {
    address: "0x2180F5cC1ddf117640963AE91868948bd3EF6838",
    decimals: 9,
    logoURI:
      "https://assets.coingecko.com/coins/images/20985/small/_VoQPDDs_400x400.jpg?1638168643",
    name: "AscensionArcade",
    symbol: "AAT",
  },
};

<DEX chain="eth" customTokens={customTokens} />;

<Wallet />

wallet

๐Ÿ’ผ <Wallet /> : example interface for interacting with your wallet. Uses components from the boilerplate: <Blockie />, <Address />, <NativeBalance />, <AddressInput />. Has the functionality to send tokens

<Wallet />

<Blockie />

<NativeBalance />

<NFTBalance />

<Contract />

๐Ÿงฐ Ethereum Hooks

useAPIContract()

๐Ÿ“‹ Runs a given function of a contract abi and returns readonly data. Uses Moralis Web3API (does not require an active web3 provider).

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • functionName (required): The function name
  • address (required): A smart contract address
  • abi (required): contract or function ABI(should be provided as an array)
  • params (optional): Parameters needed for your specific function

Example:

import { useAPIContract } from "react-moralis"

const ShowUniswapObserveValues = () => {
  const { runContractFunction, data, error, isLoading, isFetching } = useAPIContract({
    abi: usdcEthPoolAbi,
    address: usdcEthPoolAddress,
    functionName: "observe",
    params: {
      secondsAgos: [0, 10],
    },
  });

  return (<div>
    {error && <ErrorMessage error={error} />}
    <button onClick={() => runContractFunction()} disabled={isLoading}>Fetch data</button>
    {contractResponse && JSON.stringify(contractResponse)}
    </pre>}
  </div>)
}

useWeb3Contract()

๐Ÿ“‹ Runs on-chain functions. Requires active Web3 Provider.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • functionName (required): The function name
  • contractAddress (required): A smart contract address
  • abi (required): contract or function ABI(should be provided as an array)
  • params (optional): Parameters needed for your specific function

Example:

import { useWeb3Contract } from "react-moralis"

const ShowUniswapObserveValues = () => {
  const { runContractFunction, contractResponse, error, isRunning, isLoading } = useWeb3Contract({
    abi: usdcEthPoolAbi,
    contractAddress: usdcEthPoolAddress,
    functionName: "observe",
    params: {
      secondsAgos: [0, 10],
    },
  });

  return (<div>
    {error && <ErrorMessage error={error} />}
    <button onClick={() => runContractFunction()} disabled={isLoading}>Fetch data</button>
    {contractResponse && JSON.stringify(contractResponse)}
    </pre>}
  </div>)
}

useERC20Balances()

๐Ÿ’ฐ Gets all token balances of a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • to_block (optional): The block number on which the balances should be checked

Example

import { useERC20Balances } from "react-moralis";

const { fetchERC20Balances, data, isLoading, isFetching, error } =
  useERC20Balances();

const ERC20Balances = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetchERC20Balances({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
      "name": "Kylin Network",
      "symbol": "KYL",
      "logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
      "thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
      "decimals": "18",
      "balance": "123456789"
    }
  ]
}

useERC20Transfers()

๐Ÿงพ Gets ERC20 token transfers of a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • offset (optional): Offset.
  • limit (optional): Limit.

Example

import { useERC20Transfers } from "react-moralis";

const { fetchERC20Transfers, data, error, isLoading, isFetching } =
  useERC20Transfers();

const ERC20Transfers = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetchERC20Transfers({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
      "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "block_timestamp": "2021-04-02T10:07:54.000Z",
      "block_number": "12526958",
      "block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86",
      "to_address": "0x62AED87d21Ad0F3cdE4D147Fdcc9245401Af0044",
      "from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
      "value": "650000000000000000"
    }
  ]
}

useNativeBalance()

๐Ÿ’ฐ Gets native balance for a current user or specified address.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • to_block (optional): The block number on which the balances should be checked

Example:

import { useNativeBalance } from "react-moralis";

function NativeBalance() {
  const {
    getBalance,
    data: balance,
    nativeToken,
    error,
    isLoading,
  } = useNativeBalance({ chain: "ropsten" });

  return <div>{balance.formatted}</div>;
}

Example return of balance (Object)

{
  balance: '996869309795359886',
  formatted: '0.9969 ROP'
}

Example return of nativeToken (Object)

{
  name: 'Ropsten Ether',
  symbol: 'ROP',
  decimals: 18
}

useNativeTransactions()

๐Ÿงพ Gets the transactions from the current user or specified address. Returns an object with the number of transactions and the array of native transactions

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • offset (optional): Offset.
  • limit (optional): Limit.

Example

import { useNativeTransactions } from "react-moralis";

const { getNativeTransations, data, chainId, error, isLoading, isFetching } =
  useNativeTransactions();

const NativeTransactions = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button
        onClick={() => getNativeTransations({ params: { chain: "0x1" } })}
      >
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "nonce": "326595425",
      "transaction_index": "25",
      "from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
      "to_address": "0xa71db868318f0a0bae9411347cd4a6fa23d8d4ef",
      "value": "650000000000000000",
      "gas": "6721975",
      "gas_price": "20000000000",
      "input": "string",
      "receipt_cumulative_gas_used": "1340925",
      "receipt_gas_used": "1340925",
      "receipt_contract_address": "0x1d6a4cf64b52f6c73f201839aded7379ce58059c",
      "receipt_root": "string",
      "receipt_status": "1",
      "block_timestamp": "2021-04-02T10:07:54.000Z",
      "block_number": "12526958",
      "block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86"
    }
  ]
}

useNFTBalances()

๐ŸŽจ Gets all NFTs from the current user or address. Supports both ERC721 and ERC1155. Returns an object with the number of NFT objects and the array of NFT objects.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.

Example

import { useNFTBalances } from "react-moralis";

const { getNFTBalances, data, error, isLoading, isFetching } = useNFTBalances();

const NFTBalances = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => getNFTBalances({ params: { chain: "0x1" } })}>
        Refetch NFTBalances
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "token_id": "15",
      "contract_type": "ERC721",
      "owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "block_number": "88256",
      "block_number_minted": "88256",
      "token_uri": "string",
      "metadata": "string",
      "synced_at": "string",
      "amount": "1",
      "name": "CryptoKitties",
      "symbol": "RARI"
    }
  ]
}

useNFTTransfers()

๐ŸŽจ Gets the NFT transfers. Returns an object with the number of NFT transfers and the array of NFT transfers.

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • offset (optional): Offset.
  • direction (optional): The transfer direction. Available values : both, to, from . Default value : both.
  • format (optional): he format of the token id. Available values : decimal, hex. Default value : decimal.
  • limit (optional): Limit.

Example

import { useNFTTransfers } from "react-moralis";

const { fetch, data, error, isLoading, isFetching } = useNFTTransfers();

const NFTTransfers = () => {
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => fetch({ params: { chain: "0x1" } })}>
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "total": 1,
  "page": 0,
  "page_size": 500,
  "result": [
    {
      "token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "token_id": "15",
      "from_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "to_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "amount": "1",
      "contract_type": "ERC721",
      "block_number": "88256",
      "block_timestamp": "2021-06-04T16:00:15",
      "block_hash": "string",
      "transaction_hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
      "transaction_type": "string",
      "transaction_index": "string",
      "log_index": 0
    }
  ]
}

useChain()

โ›“ Hook for fast network switching or getting info about current network. To change the current network, set the target chainId to switchNetwork function. If the user does not have the target network in the wallet, it will automatically ask permission to add it to the wallet.

Example:

import { useChain } from "react-moralis";

function Chains() {
  const { switchNetwork, chainId, chain, account } = useChain();
  return (
    <>
      <button onClick={() => switchNetwork("0x1")}>Switch to Ethereum</button>
      <p>Current chainId: {chainId}</p>
    </>
  );
}

useTokenPrice()

๐Ÿ’ฐ Gets the price nominated in the native token and usd for a given token contract address

Options:

  • chain (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain (if the chain is not supported it will use the Eth chain).
  • address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
  • exchange (optional): The factory name or address of the token exchange. Possible exchanges, for different chains are: ETH mainnet: uniswap-v3, sushiswap, uniswap-v2, BSC mainnet: pancakeswap-v2, pancakeswap-v1. Polygon mainnet: quickswap. If no exchange is specified, all exchanges are checked (in the order as listed above) until a valid pool has been found. Note that this request can take more time. So specifying the exchange will result in faster responses most of the time.
  • to_block (optional): Returns the price for a given blocknumber (historical price-data).

Example

import { useTokenPrice } from "react-moralis";

const TokenPrice = () => {
  const {
    fetchTokenPrice,
    data: formattedData,
    error,
    isLoading,
    isFetching,
  } = useTokenPrice({ address: "0x1f9840...1f984", chain: "eth" });

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button
        onClick={() =>
          fetchTokenPrice({ params: { address: "0x6...361", chain: "bsc" } })
        }
      >
        Refetch
      </button>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Example return (Object)

{
  "exchangeAddress": "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  "exchangeName": "Uniswap v3",
  "formattedNative": "0.004695 ETH",
  "formattedUsd": "$20.38",
  "nativePrice": {
    "decimals": 18,
    "name": "Ether",
    "symbol": "ETH",
    "value": "4695118425598734"
  },
  "usdPrice": 20.37791922835578
}

DEX Hooks

useOneInchQuote()

๐Ÿ’ธ Hook for getting swap quote info.

Example:

import { useOneInchQuote } from "react-moralis";

function Quote() {
  const { getQuote, data, isFetching, isLoading, error } = useOneInchQuote({
    chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
    fromTokenAddress: "0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4", // The token you want to swap
    toTokenAddress: "0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4", // The token you want to receive
    amount: 1000,
  });
  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
}

useOneInchQuote()

๐Ÿ’ธ Hook for swap.

Example:

import { useOneInchQuote } from "react-moralis";

function Swap() {
  const { swap, data, isFetching, isLoading, error } = useOneInchSwap();

  const options = {
    chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
    fromTokenAddress: "0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4", // The token you want to swap
    toTokenAddress: "0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4", // The token you want to receive
    amount: 1000,
    fromAddress: "0x6217e65d864d77DEcbFF0CFeFA13A93f7C1dD064", // Your wallet address
    slippage: 1,
  };

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <button onClick={() => swap(options)}>Swap</button>
    </div>
  );
}

useOneInchTokens()

๐Ÿ’ธ Hook for get supported token list.

Example:

import { useOneInchQuote } from "react-moralis";

const SupportedTokens = () => {
  const { getSupportedTokens, data, isFetching, isLoading, error } =
    useOneInchTokens({ chain: "bsc" });

  return (
    <div>
      {error && <>{JSON.stringify(error)}</>}
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

Where to host your dApp?


Author: mairh
Source code: https://github.com/mairh/ethkit
License: MIT license
#react-native  #javascript 

Joshua Yates

Joshua Yates

1646723747

How to Build a Cross-chain Zapper dApp with ReactJS and Moralis

How to Build a Cross-Chain Zapper dApp with ReactJS Using Moralis API and Serverless Real-Time Transactions

In this article, we go through how to build a cross-chain Zapper dApp with ReactJS using Moralis API and serverless real-time transactionsยฐ

Youโ€™ve undoubtedly heard a lot about dApps, but you might not be sure how to build one quickly. Many in the IT world seem to have their own definition of what constitutes a dApp, and the more you delve into it, the more technical it all becomes. Put simply, dApp is short for โ€œdecentralized applicationโ€, and is a Web3 app. These dApps generally require a lot of work to bring to market. However, if you utilize a robust Web3 backend infrastructure platform such as Moralis, you can significantly reduce your dApp development time!

In this tutorial, weโ€™ll go over how to use Moralisโ€™ API and serverless real-time transactions to build a cross-chain Zapper dApp with ReactJS.

#blockchain #dapp #react #moralis #serverless #web3

Mathew Rini

1615544450

How to Select and Hire the Best React JS and React Native Developers?

Since March 2020 reached 556 million monthly downloads have increased, It shows that React JS has been steadily growing. React.js also provides a desirable amount of pliancy and efficiency for developing innovative solutions with interactive user interfaces. Itโ€™s no surprise that an increasing number of businesses are adopting this technology. How do you select and recruit React.js developers who will propel your project forward? How much does a React developer make? Weโ€™ll bring you here all the details you need.

What is React.js?

Facebook built and maintains React.js, an open-source JavaScript library for designing development tools. React.js is used to create single-page applications (SPAs) that can be used in conjunction with React Native to develop native cross-platform apps.

React vs React Native

  • React Native is a platform that uses a collection of mobile-specific components provided by the React kit, while React.js is a JavaScript-based library.
  • React.js and React Native have similar syntax and workflows, but their implementation is quite different.
  • React Native is designed to create native mobile apps that are distinct from those created in Objective-C or Java. React, on the other hand, can be used to develop web apps, hybrid and mobile & desktop applications.
  • React Native, in essence, takes the same conceptual UI cornerstones as standard iOS and Android apps and assembles them using React.js syntax to create a rich mobile experience.

What is the Average React Developer Salary?

In the United States, the average React developer salary is $94,205 a year, or $30-$48 per hour, This is one of the highest among JavaScript developers. The starting salary for junior React.js developers is $60,510 per year, rising to $112,480 for senior roles.

* React.js Developer Salary by Country

  • United States- $120,000
  • Canada - $110,000
  • United Kingdom - $71,820
  • The Netherlands $49,095
  • Spain - $35,423.00
  • France - $44,284
  • Ukraine - $28,990
  • India - $9,843
  • Sweden - $55,173
  • Singapore - $43,801

In context of software developer wage rates, the United States continues to lead. In high-tech cities like San Francisco and New York, average React developer salaries will hit $98K and $114per year, overall.

However, the need for React.js and React Native developer is outpacing local labour markets. As a result, many businesses have difficulty locating and recruiting them locally.

Itโ€™s no surprise that for US and European companies looking for professional and budget engineers, offshore regions like India are becoming especially interesting. This area has a large number of app development companies, a good rate with quality, and a good pool of React.js front-end developers.

As per Linkedin, the countryโ€™s IT industry employs over a million React specialists. Furthermore, for the same or less money than hiring a React.js programmer locally, you may recruit someone with much expertise and a broader technical stack.

How to Hire React.js Developers?

  • Conduct thorough candidate research, including portfolios and areas of expertise.
  • Before you sit down with your interviewing panel, do some homework.
  • Examine the final outcome and hire the ideal candidate.

Why is React.js Popular?

React is a very strong framework. React.js makes use of a powerful synchronization method known as Virtual DOM, which compares the current page architecture to the expected page architecture and updates the appropriate components as long as the user input.

React is scalable. it utilises a single language, For server-client side, and mobile platform.

React is steady.React.js is completely adaptable, which means it seldom, if ever, updates the user interface. This enables legacy projects to be updated to the most new edition of React.js without having to change the codebase or make a few small changes.

React is adaptable. It can be conveniently paired with various state administrators (e.g., Redux, Flux, Alt or Reflux) and can be used to implement a number of architectural patterns.

Is there a market for React.js programmers?
The need for React.js developers is rising at an unparalleled rate. React.js is currently used by over one million websites around the world. React is used by Fortune 400+ businesses and popular companies such as Facebook, Twitter, Glassdoor and Cloudflare.

Final thoughts:

As youโ€™ve seen, locating and Hire React js Developer and Hire React Native developer is a difficult challenge. You will have less challenges selecting the correct fit for your projects if you identify growing offshore locations (e.g. India) and take into consideration the details above.

If you want to make this process easier, You can visit our website for more, or else to write a email, weโ€™ll help you to finding top rated React.js and React Native developers easier and with strives to create this operation

#hire-react-js-developer #hire-react-native-developer #react #react-native #react-js #hire-react-js-programmer