Integrate Web3Auth with the Aleph Zero 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
Aleph Zero Blockchain blockchain calls like getting the user's account
,
fetching balance
, signing transactions, sending transactions, and interacting with smart
contracts. We have highlighted a few key examples to get you started quickly on that.
Installation
To interact with an EVM blockchain in React Native, you can use any EIP1193
compatible package like
web3.js
, ethers.js
etc.
In this reference, we're using ethers.js
to demonstrate how to make blockchain calls using it with Web3Auth.
- Install the
ethers.js
package usingnpm
oryarn
:
npm install @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.