|
| 1 | +--- |
| 2 | +title: Integrate Web3Auth with the Unichain Blockchain in React Native |
| 3 | +sidebar_label: React Native |
| 4 | +image: "banners/unichain.png" |
| 5 | +keywords: [react-native, unichain, web3auth, authentication, blockchain] |
| 6 | +description: |
| 7 | + "Integrate Web3Auth with the Unichain Blockchain in React Native | Documentation - Web3Auth" |
| 8 | +--- |
| 9 | + |
| 10 | +import InstallationSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-installation.mdx"; |
| 11 | +import GetAccountSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-get-account.mdx"; |
| 12 | +import UserInfoSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-user-info.mdx"; |
| 13 | +import GetBalanceSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-get-balance.mdx"; |
| 14 | +import InitialisationSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-initialisation.mdx"; |
| 15 | +import SignMessageSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-sign-message.mdx"; |
| 16 | +import SendTransactionSnippet from "@site/src/common/docs/react-native-connect-blockchain/_evm-send-transaction.mdx"; |
| 17 | +import Tabs from "@theme/Tabs"; |
| 18 | +import TabItem from "@theme/TabItem"; |
| 19 | +import SEO from "@site/src/components/SEO"; |
| 20 | + |
| 21 | +<SEO |
| 22 | + title="Integrate Web3Auth with the Unichain Blockchain in React Native" |
| 23 | + description="Integrate Web3Auth with the Unichain Blockchain in React Native | Documentation - Web3Auth" |
| 24 | + image="https://web3auth.io/docs/banners/unichain.png" |
| 25 | + slug="/connect-blockchain/evm/unichain/react-native" |
| 26 | +/> |
| 27 | + |
| 28 | +While using the Web3Auth React Native SDK, you get a |
| 29 | +[`EIP1193`](https://eips.ethereum.org/EIPS/eip-1193) provider, similar to the |
| 30 | +[Metamask Provider](https://docs.metamask.io/guide/ethereum-provider.html). This provider can be |
| 31 | +used with libraries like [`web3.js`](https://web3js.readthedocs.io/en/v1.2.8/getting-started.html), |
| 32 | +[`ethers.js`](https://docs.ethers.io/v5/getting-started/) etc. to make |
| 33 | +[Unichain](https://www.unichain.org/) blockchain calls like getting the user's `account`, fetching |
| 34 | +`balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, |
| 35 | +etc. We have highlighted a few here to get you started quickly on that. |
| 36 | + |
| 37 | +## Installation |
| 38 | + |
| 39 | +<InstallationSnippet /> |
| 40 | + |
| 41 | +## Initializing Provider |
| 42 | + |
| 43 | +Using `eip155` as `chainNamespace` while initializing `web3auth` will provide an |
| 44 | +[`EIP1193`](https://eips.ethereum.org/EIPS/eip-1193) compatible provider as **`web3auth.provider`** |
| 45 | +after successful authentication. |
| 46 | + |
| 47 | +### Getting the `chainConfig` |
| 48 | + |
| 49 | +<Tabs |
| 50 | + defaultValue="mainnet" |
| 51 | + values={[ |
| 52 | + { label: "Mainnet", value: "mainnet", }, |
| 53 | + { label: "Testnet", value: "testnet", }, |
| 54 | + ]} |
| 55 | +> |
| 56 | +<TabItem |
| 57 | + value="mainnet" |
| 58 | +> |
| 59 | + |
| 60 | +```typescript |
| 61 | +const chainConfig = { |
| 62 | + chainNamespace: ChainNamespace.EIP155, |
| 63 | + chainId: "0x82", // hex of 130 |
| 64 | + rpcTarget: "https://mainnet.unichain.org", |
| 65 | + // Avoid using public rpcTarget in production. |
| 66 | + // Use services like Infura, Quicknode etc |
| 67 | + displayName: "Unichain Mainnet", |
| 68 | + blockExplorer: "https://uniscan.xyz", |
| 69 | + ticker: "ETH", |
| 70 | + tickerName: "ETH", |
| 71 | +}; |
| 72 | +``` |
| 73 | + |
| 74 | +</TabItem> |
| 75 | + |
| 76 | +<TabItem |
| 77 | + value="testnet" |
| 78 | +> |
| 79 | + |
| 80 | +```typescript |
| 81 | +const chainConfig = { |
| 82 | + chainNamespace: ChainNamespace.EIP155, |
| 83 | + chainId: "0x515", // hex of 1301 |
| 84 | + rpcTarget: "https://sepolia.unichain.org", |
| 85 | + // Avoid using public rpcTarget in production. |
| 86 | + // Use services like Infura, Quicknode etc |
| 87 | + displayName: "Unichain Sepolia Testnet", |
| 88 | + blockExplorer: "https://sepolia.uniscan.xyz/", |
| 89 | + ticker: "ETH", |
| 90 | + tickerName: "ETH", |
| 91 | +}; |
| 92 | +``` |
| 93 | + |
| 94 | +</TabItem> |
| 95 | +</Tabs> |
| 96 | + |
| 97 | +## Initialize |
| 98 | + |
| 99 | +<InitialisationSnippet /> |
| 100 | + |
| 101 | +## Get User Info |
| 102 | + |
| 103 | +<UserInfoSnippet /> |
| 104 | + |
| 105 | +## Get Account |
| 106 | + |
| 107 | +<GetAccountSnippet /> |
| 108 | + |
| 109 | +## Get Balance |
| 110 | + |
| 111 | +<GetBalanceSnippet /> |
| 112 | + |
| 113 | +## Send Transaction |
| 114 | + |
| 115 | +<SendTransactionSnippet /> |
| 116 | + |
| 117 | +## Sign a message |
| 118 | + |
| 119 | +<SignMessageSnippet /> |
0 commit comments