Integrate Web3Auth with the Soneium 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
Soneium 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 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.