> For the complete documentation index, see [llms.txt](/llms.txt).

# Integrate Embedded Wallets with the Ethereum Blockchain in React Native

While using the Web3Auth React Native SDK, you get a [EIP1193](https://eips.ethereum.org/EIPS/eip-1193) provider, similar to the [MetaMask Provider](/metamask-connect/evm/reference/provider-api/). This provider can be used with libraries like [web3.js](https://docs.web3js.org/), [ethers.js](https://docs.ethers.io/v5/getting-started/) etc. to make [Ethereum](https://ethereum.org/) 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 Ethereum[​](#chain-details-for-ethereum "Direct link to Chain details for Ethereum")

- Mainnet
- Sepolia Testnet
- Holesky Testnet

- **Chain ID:** 0x1
- **RPC URL:** You can use our bundled RPC service from Infura, or your own choice of RPC service for production.
- **Display Name:** Ethereum Mainnet
- **Block Explorer Link:** `https://etherscan.io`
- **Ticker:** ETH
- **Ticker Name:** Ethereum

- **Chain ID:** 0xaa36a7
- **Public RPC URL:** `https://ethereum-sepolia.publicnode.com`
- **Display Name:** Ethereum Sepolia Testnet
- **Block Explorer Link:** `https://sepolia.etherscan.io`
- **Ticker:** ETH
- **Ticker Name:** SepoliaETH

- **Chain ID:** 0x4268
- **Public RPC URL:** `https://rpc.holesky.ethpandaops.io`
- **Display Name:** Ethereum Holesky Testnet
- **Block Explorer Link:** `https://holesky.etherscan.io`
- **Ticker:** ETH
- **Ticker Name:** HoleskyETH

## Installation[​](#installation "Direct link to Installation")

To interact with an EVM blockchain in React Native, you can use any [EIP1193](https://eips.ethereum.org/EIPS/eip-1193) compatible package such as [web3.js](https://docs.web3js.org/) or [ethers.js](https://docs.ethers.io/v5/getting-started/).

In this example, we use `ethers.js` to demonstrate how to make blockchain calls using it with Web3Auth.

- Install the `ethers.js` package using `npm` or `yarn`:

- 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](https://docs.ethers.org/v5/cookbook/react-native/#cookbook-reactnative) to set up the `ethers.js` package in React Native.

## Initializing provider[​](#initializing-provider "Direct link to Initializing provider")

Using `eip155` as `chainNamespace` while initializing `web3auth` will provide an [EIP1193](https://eips.ethereum.org/EIPS/eip-1193) compatible provider as **`web3auth.provider`** after successful authentication.

### Getting the `chainConfig`[​](#getting-the-chainconfig "Direct link to getting-the-chainconfig")

- Mainnet
- Testnet

```
import { getEvmChainConfig } from '@web3auth/base'

const chainConfig = getEvmChainConfig(1, 'your_web3auth_client_id')

```

```
import { getEvmChainConfig } from '@web3auth/base'

const chainConfig = getEvmChainConfig(11155111, 'your_web3auth_client_id')

```

## Initialize[​](#initialize "Direct link to Initialize")

```
import * as WebBrowser from '@toruslabs/react-native-web-browser'
import EncryptedStorage from 'react-native-encrypted-storage'
import Web3Auth, { LOGIN_PROVIDER, WEB3AUTH_NETWORK } from '@web3auth/react-native-sdk'
import '@ethersproject/shims'
import { ethers } from 'ethers'
import { EthereumPrivateKeyProvider } from '@web3auth/ethereum-provider'

const [provider, setProvider] = useState<IProvider | null>(null)

const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({
  config: {
    chainConfig,
  },
})

const web3auth = new Web3Auth(WebBrowser, EncryptedStorage, {
  clientId,
  network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or other networks
})

await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey)

setProvider(ethereumPrivateKeyProvider)

```

## Get account[​](#get-account "Direct link to Get account")

```
// For ethers v5
// const ethersProvider = new ethers.providers.Web3Provider(this.provider);
const ethersProvider = new ethers.BrowserProvider(provider!)

// For ethers v5
// const signer = ethersProvider.getSigner();
const signer = await ethersProvider.getSigner()

// Get user's Ethereum public address
const address = signer.getAddress()
uiConsole(address)

```

## Get balance[​](#get-balance "Direct link to Get balance")

```
// For ethers v5
// const ethersProvider = new ethers.providers.Web3Provider(this.provider);
const ethersProvider = new ethers.BrowserProvider(provider!)

// For ethers v5
// const signer = ethersProvider.getSigner();
const signer = await ethersProvider.getSigner()

// Get user's Ethereum public address
const address = signer.getAddress()

// Get user's balance in ether
// For ethers v5
// const balance = ethers.utils.formatEther(
// await ethersProvider.getBalance(address) // Balance is in wei
// );
const balance = ethers.formatEther(
  await ethersProvider.getBalance(address) // Balance is in wei
)

```

## Send transaction[​](#send-transaction "Direct link to Send transaction")

```
const ethersProvider = ethers.getDefaultProvider(providerUrl)
const wallet = new ethers.Wallet(key, ethersProvider)

const destination = '0x40e1c367Eca34250cAF1bc8330E9EddfD403fC56'

// Convert 1 ether to wei
const amount = ethers.utils.parseEther('0.001')

// Submit transaction to the blockchain
const tx = await wallet.sendTransaction({
  to: destination,
  value: amount,
  maxPriorityFeePerGas: '5000000000', // Max priority fee per gas
  maxFeePerGas: '6000000000000', // Max fee per gas
})

```

## Sign a message[​](#sign-a-message "Direct link to Sign a message")

```
// For ethers v5
// const ethersProvider = new ethers.providers.Web3Provider(this.provider);
const ethersProvider = new ethers.BrowserProvider(provider!)

// For ethers v5
// const signer = ethersProvider.getSigner();
const signer = await ethersProvider.getSigner()
const originalMessage = 'YOUR_MESSAGE'

// Sign the message
const signedMessage = await signer.signMessage(originalMessage)

```
