Integrate Embedded Wallets with the Zetachain Blockchain in React Native
While using the Embedded Wallets 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 Zetachain blockchain calls like getting the user's account, fetching balance, sign transaction, send transaction, read from and write to the smart contract, etc.
Chain details for Zetachain
- Mainnet
- Chain ID: 0x1B58
- Public RPC URL:
https://zetachain-mainnet.g.allthatnode.com/archive/evm - Display Name: ZetaChain Mainnet
- Block Explorer Link:
https://zetachain.blockscout.com - Ticker: ZETA
- Ticker Name: ZetaChain
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'
We have followed this guide to set up the ethers.js package in React Native.
Initializing provider
Using eip155 as chainNamespace while initializing web3auth will provide an EIP1193 compatible provider as web3auth.provider after successful authentication.