Integrate Embedded Wallets with the Morph Blockchain in React Native
While using the Web3Auth React Native SDK, you get a EIP1193 provider, similar to the MetaMask Provider. This provider can be used with libraries like web3.js, ethers.js etc. to make Morph blockchain calls like getting the user's account, fetching balance, sign transaction, send transaction, read from and write to the smart contract, etc. We have highlighted a few here to get you started.
Chain details for Morph
- Testnet
- Holesky
- Chain ID: 0xa96
- Public RPC URL:
https://rpc-testnet.morphl2.io - Display Name: Morph Testnet
- Block Explorer Link:
https://explorer-testnet.morphl2.io - Ticker: ETH
- Ticker Name: Ethereum
- Chain ID: 0xafa
- Public RPC URL:
https://rpc-holesky.morphl2.io - Display Name: Morph Holesky
- Block Explorer Link:
https://explorer-holesky.morphl2.io - Ticker: ETH
- Ticker Name: Ethereum
Installation
To interact with an EVM blockchain in React Native, you can use any EIP1193 compatible package such as
web3.js or ethers.js.
In this example, we use ethers.js to demonstrate how to make blockchain calls using it with Web3Auth.
- Install the
ethers.jspackage usingnpmoryarn:
- npm
- Yarn
- pnpm
- Bun
npm install @ethersproject/shims ethers
yarn add @ethersproject/shims ethers
pnpm add @ethersproject/shims ethers
bun add @ethersproject/shims ethers
- Import the packages and shims into your codebase:
// Import the required shims
import '@ethersproject/shims'
// Import the ethers library
import { ethers } from 'ethers'
info
We have followed this guide to set up the ethers.js package in React Native.