22title : " Initializing Core Kit SFA React Native SDK"
33sidebar_label : " Initialize"
44displayed_sidebar : sdk
5- description : " Web3Auth Core Kit Single Factor Auth React Native SDK - Initialize | Documentation - Web3Auth"
5+ description :
6+ " Web3Auth Core Kit Single Factor Auth React Native SDK - Initialize | Documentation - Web3Auth"
67---
78
89import ChainConfig from " @site/src/common/sdk/pnp/web/_chain-config.mdx" ;
@@ -11,7 +12,8 @@ import InstantiatingProvider from "@site/src/common/sdk/core-kit/sfa/_instantiat
1112import TabItem from " @theme/TabItem" ;
1213import Tabs from " @theme/Tabs" ;
1314
14- After Installation, the next step to use Web3Auth Single Factor Auth Web SDK is to Initialize the SDK.
15+ After Installation, the next step to use Web3Auth Single Factor Auth Web SDK is to Initialize the
16+ SDK.
1517
1618However, the Initialization is a two-step process, ie.
1719
@@ -23,7 +25,7 @@ However, the Initialization is a two-step process, ie.
2325#### Import the ` Web3Auth ` class from ` @web3auth/single-factor-auth-react-native ` package.
2426
2527``` js
26- import { Web3Auth } from " @web3auth/single-factor-auth-react-native" ;
28+ import Web3Auth from " @web3auth/single-factor-auth-react-native" ;
2729```
2830
2931#### Assign the ` Web3Auth ` class to a variable
@@ -40,25 +42,27 @@ import { Web3Auth } from "@web3auth/single-factor-auth-react-native";
4042
4143``` javascript
4244import * as SecureStore from " expo-secure-store" ;
43- import { Web3Auth } from " @web3auth/single-factor-auth-react-native" ;
45+ import Web3Auth from " @web3auth/single-factor-auth-react-native" ;
4446
4547const web3auth = new Web3Auth (SecureStore, SdkInitOptions);
4648```
4749
48- The react native SFA Web3Auth constructor takes ` SecureStore ` and an object with ` SdkInitOptions ` as parameters for the expo-managed workflow.
50+ The react native SFA Web3Auth constructor takes ` SecureStore ` and an object with ` SdkInitOptions ` as
51+ parameters for the expo-managed workflow.
4952
5053</TabItem >
5154
5255<TabItem value = " bare" >
5356
5457``` javascript
5558import EncryptedStorage from " react-native-encrypted-storage" ;
56- import { Web3Auth } from " @web3auth/single-factor-auth-react-native" ;
59+ import Web3Auth from " @web3auth/single-factor-auth-react-native" ;
5760
5861const web3auth = new Web3Auth (EncryptedStorage, SdkInitOptions);
5962```
6063
61- The react native SFA Web3Auth constructor takes ` EncryptedStorage ` and an object with ` SdkInitOptions ` as parameters for the bare workflow.
64+ The react native SFA Web3Auth constructor takes ` EncryptedStorage ` and an object with
65+ ` SdkInitOptions ` as parameters for the bare workflow.
6266
6367</TabItem >
6468</Tabs >
@@ -144,7 +148,7 @@ export interface SdkInitOptions {
144148``` ts
145149const web3auth = new Web3Auth (SecureStore , {
146150 clientId: " WEB3AUTH_CLIENT_ID" , // Get your Client ID from the Web3Auth Dashboard
147- web3AuthNetwork: " sapphire_mainnet " ,
151+ web3AuthNetwork: WEB3AUTH_NETWORK . SAPPHIRE_MAINNET ,
148152 usePnPKey: false , // By default, this sdk returns CoreKitKey
149153});
150154```
@@ -156,7 +160,7 @@ const web3auth = new Web3Auth(SecureStore, {
156160``` ts
157161const web3auth = new Web3Auth (EncryptedStorage , {
158162 clientId: " WEB3AUTH_CLIENT_ID" , // Get your Client ID from the Web3Auth Dashboard
159- web3AuthNetwork: " sapphire_mainnet " ,
163+ web3AuthNetwork: WEB3AUTH_NETWORK . SAPPHIRE_MAINNET ,
160164 usePnPKey: false , // By default, this sdk returns CoreKitKey
161165});
162166```
@@ -172,8 +176,9 @@ const web3auth = new Web3Auth(EncryptedStorage, {
172176
173177#### ` init() `
174178
175- To complete the initialization process, we need to initialize the ` Web3Auth ` instance, which we named ` web3auth ` . This is achieved by calling the
176- ` init() ` function of the previously created ` web3auth ` instance, using a ** private key provider** .
179+ To complete the initialization process, we need to initialize the ` Web3Auth ` instance, which we
180+ named ` web3auth ` . This is achieved by calling the ` init() ` function of the previously created
181+ ` web3auth ` instance, using a ** private key provider** .
177182
178183``` ts
179184await web3auth .init (privateKeyProvider );
@@ -193,9 +198,9 @@ await web3auth.init(privateKeyProvider);
193198
194199``` ts
195200import * as SecureStore from " expo-secure-store" ;
196- import { Web3Auth } from " @web3auth/single-factor-auth-react-native" ;
201+ import Web3Auth from " @web3auth/single-factor-auth-react-native" ;
197202import { EthereumPrivateKeyProvider } from " @web3auth/ethereum-provider" ;
198- import { CHAIN_NAMESPACES } from " @web3auth/base" ;
203+ import { CHAIN_NAMESPACES , WEB3AUTH_NETWORK } from " @web3auth/base" ;
199204
200205// Swap with a different provider if you want to use a different blockchain
201206const privateKeyProvider = new EthereumPrivateKeyProvider ({
@@ -214,7 +219,7 @@ const privateKeyProvider = new EthereumPrivateKeyProvider({
214219
215220const web3auth = new Web3Auth (SecureStore , {
216221 clientId: " WEB3AUTH_CLIENT_ID" , // Get your Client ID from the Web3Auth Dashboard
217- web3AuthNetwork: " sapphire_mainnet " ,
222+ web3AuthNetwork: WEB3AUTH_NETWORK . SAPPHIRE_MAINNET ,
218223 usePnPKey: false , // By default, this sdk returns CoreKitKey
219224});
220225
@@ -227,9 +232,9 @@ await web3auth.init(privateKeyProvider);
227232
228233``` ts
229234import EncryptedStorage from " react-native-encrypted-storage" ;
230- import { Web3Auth } from " @web3auth/single-factor-auth-react-native" ;
235+ import Web3Auth from " @web3auth/single-factor-auth-react-native" ;
231236import { EthereumPrivateKeyProvider } from " @web3auth/ethereum-provider" ;
232- import { CHAIN_NAMESPACES } from " @web3auth/base" ;
237+ import { CHAIN_NAMESPACES , WEB3AUTH_NETWORK } from " @web3auth/base" ;
233238
234239// Swap with a different provider if you want to use a different blockchain
235240const privateKeyProvider = new EthereumPrivateKeyProvider ({
@@ -248,7 +253,7 @@ const privateKeyProvider = new EthereumPrivateKeyProvider({
248253
249254const web3auth = new Web3Auth (EncryptedStorage , {
250255 clientId: " WEB3AUTH_CLIENT_ID" , // Get your Client ID from the Web3Auth Dashboard
251- web3AuthNetwork: " sapphire_mainnet " ,
256+ web3AuthNetwork: WEB3AUTH_NETWORK . SAPPHIRE_MAINNET ,
252257 usePnPKey: false , // By default, this sdk returns CoreKitKey
253258});
254259
0 commit comments