Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions embedded-wallets/authentication/custom-connections/auth0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -228,30 +228,20 @@ Read more about initializing the Flutter SDK [here](/embedded-wallets/sdk/flutte
### React Native

```tsx
const web3auth = new Web3Auth(WebBrowser, SecureStore, {
clientId,
network: OPENLOGIN_NETWORK.SAPPHIRE_MAINNET, // SAPPHIRE_MAINNET or SAPPHIRE_DEVNET
loginConfig: {
// focus-start
jwt: {
verifier: 'YOUR_AUTH0_VERIFIER_NAME', // Please create a verifier on the developer dashboard and pass the name here
typeOfLogin: 'jwt',
clientId: 'AUTH0_CLIENT_ID_123ABcdefg4HiJKlMno4P5QR6stUvWXY', // use your app client id you got from auth0
},
// focus-end
},
})
```
import { AUTH_CONNECTION, useWeb3AuthConnect } from '@web3auth/react-native-sdk'

```tsx
const web3authResponse = await web3auth.login({
redirectUrl: resolvedRedirectUrl,
const { connectTo } = useWeb3AuthConnect()

await connectTo({
authConnection: AUTH_CONNECTION.CUSTOM,
// focus-start
loginProvider: 'jwt',
authConnectionId: 'YOUR_AUTH0_CONNECTION_ID', // Connection ID from the dashboard
extraLoginOptions: {
domain: 'https://YOUR-AUTH0-DOMAIN', // Please append "https://" before your domain
verifierIdField: 'sub', // For SMS & Email Passwordless, use "name" as verifierIdField
domain: 'https://YOUR-AUTH0-DOMAIN', // Include "https://"
verifierIdField: 'sub', // For SMS and email passwordless, use "name"
},
// focus-end
})
```

Read more about [custom authentication in the React Native SDK](/embedded-wallets/sdk/react-native/advanced/custom-authentication).
61 changes: 18 additions & 43 deletions embedded-wallets/authentication/custom-connections/firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -278,55 +278,30 @@ Read more about initializing the Flutter SDK [here](/embedded-wallets/sdk/flutte

### React Native

```tsx
const web3auth = new Web3Auth(WebBrowser, SecureStore, {
clientId,
network: OPENLOGIN_NETWORK.SAPPHIRE_MAINNET, // SAPPHIRE_MAINNET or SAPPHIRE_DEVNET
loginConfig: {
// focus-start
jwt: {
verifier: 'YOUR_JWT_VERIFIER_NAME', // Please create a verifier on the developer dashboard and pass the name here
typeOfLogin: 'jwt',
},
// focus-end
},
})
```

```tsx
import auth from '@react-native-firebase/auth'
import { GoogleSignin } from '@react-native-google-signin/google-signin'
import { AUTH_CONNECTION, useWeb3AuthConnect } from '@web3auth/react-native-sdk'

async function signInWithFirebase() {
try {
GoogleSignin.configure({
webClientId: '461819774167-5iv443bdf5a6pnr2drt4tubaph270obl.apps.googleusercontent.com',
})
// Check if your device supports Google Play
await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true })
// Get the user's ID token
const { idToken } = await GoogleSignin.signIn()
// Create a Google credential with the token
const googleCredential = auth.GoogleAuthProvider.credential(idToken)
const { connectTo } = useWeb3AuthConnect()

// Sign-in the user with the credential
const res = await auth().signInWithCredential(googleCredential)
async function signInWithFirebase() {
GoogleSignin.configure({ webClientId: 'YOUR_GOOGLE_WEB_CLIENT_ID' })
await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true })
const { data } = await GoogleSignin.signIn()

const idToken = await res.user.getIdToken(true)
const googleCredential = auth.GoogleAuthProvider.credential(data?.idToken ?? null)
const { user } = await auth().signInWithCredential(googleCredential)
const idToken = await user.getIdToken(true)

// focus-start
await web3auth.login({
redirectUrl: resolvedRedirectUrl,
mfaLevel: 'default', // Pass on the MFA level of your choice: default, optional, mandatory, none
loginProvider: 'jwt',
extraLoginOptions: {
id_token: idToken,
verifierIdField: 'sub', // same as your JWT Verifier ID on the dashboard
},
})
// focus-end
} catch (error) {
console.error(error)
}
// focus-start
await connectTo({
authConnection: AUTH_CONNECTION.CUSTOM,
authConnectionId: 'YOUR_FIREBASE_CONNECTION_ID', // Connection ID from the dashboard
idToken, // no browser opens when you pass an idToken
})
// focus-end
}
```

Read more about [custom authentication in the React Native SDK](/embedded-wallets/sdk/react-native/advanced/custom-authentication#bring-your-own-jwt-idtoken).
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
```tsx
// 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)
const [address] = await walletClient.getAddresses()
```
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
```tsx
// For ethers v5
// const ethersProvider = new ethers.providers.Web3Provider(this.provider);
const ethersProvider = new ethers.BrowserProvider(provider!)
import { formatEther } from 'viem'

// 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
)
const [address] = await walletClient.getAddresses()
const balance = formatEther(await publicClient.getBalance({ address }))
```
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
```typescript
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'
Set up the SDK as described in [Get started](/embedded-wallets/sdk/react-native/), with the chain
configured on the dashboard or in `web3AuthOptions.chains`. After sign-in, read the EIP-1193
provider from `useWeb3Auth().connection` and create viem clients:

const [provider, setProvider] = useState<IProvider | null>(null)
```tsx
import { useWeb3Auth } from '@web3auth/react-native-sdk'
import { createPublicClient, createWalletClient, custom } from 'viem'

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

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

await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey)

setProvider(ethereumPrivateKeyProvider)
// Call after the user signs in (isConnected is true)
const transport = custom(connection!.ethereumProvider!)
const walletClient = createWalletClient({ transport })
const publicClient = createPublicClient({ transport })
```
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
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`:
Use any [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible library with the provider
from the SDK. These examples use [viem](https://viem.sh):

```bash npm2yarn
npm install @ethersproject/shims ethers
```

- Import the packages and shims into your codebase:

```tsx
// Import the required shims
import '@ethersproject/shims'

// Import the ethers library
import { ethers } from 'ethers'
npm install viem
```

:::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.

:::
To use Wagmi hooks instead, see
[Ethereum hooks (Wagmi)](/embedded-wallets/sdk/react-native/ethereum-hooks).
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import SendTransactionSnippet from './_evm-send-transaction.mdx'

<InstallationSnippet />

## 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.

## Initialize

<InitialisationSnippet />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
```tsx
const ethersProvider = ethers.getDefaultProvider(providerUrl)
const wallet = new ethers.Wallet(key, ethersProvider)
import { parseEther } from 'viem'

const destination = '0x40e1c367Eca34250cAF1bc8330E9EddfD403fC56'
const [account] = await walletClient.getAddresses()

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

// Submit transaction to the blockchain
//focus-start
const tx = await wallet.sendTransaction({
to: destination,
value: amount,
maxPriorityFeePerGas: '5000000000', // Max priority fee per gas
maxFeePerGas: '6000000000000', // Max fee per gas
const hash = await walletClient.sendTransaction({
account,
to: '0x40e1c367Eca34250cAF1bc8330E9EddfD403fC56',
value: parseEther('0.001'),
chain: null, // use the provider's active chain
})
//focus-end

const receipt = await publicClient.waitForTransactionReceipt({ hash })
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
```tsx
// For ethers v5
// const ethersProvider = new ethers.providers.Web3Provider(this.provider);
const ethersProvider = new ethers.BrowserProvider(provider!)
const [account] = await walletClient.getAddresses()

// 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)
const signature = await walletClient.signMessage({
account,
message: 'YOUR_MESSAGE',
})
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Aleph Zero Blockchain in React
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsAlephZero from '../../_general-connect-blockchain/_aleph-zero.mdx'

While using the Embedded Wallets 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 [Aleph Zero](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.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Aleph Zero](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.

## Chain details for Aleph Zero

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Ancient8 Blockchain in React N
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsAncient8 from '../../_general-connect-blockchain/_ancient8.mdx'

While using the Embedded Wallets 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 [Ancient8](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.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Ancient8](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.

## Chain details for Ancient8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Arbitrum Blockchain in React N
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsArbitrum from '../../_general-connect-blockchain/_arbitrum.mdx'

While using the Embedded Wallets 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 [Arbitrum](https://arbitrum.io/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Arbitrum](https://arbitrum.io/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.

## Chain details for Arbitrum

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Arc Blockchain in React Native
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsArc from '../../_general-connect-blockchain/_arc.mdx'

While using the Embedded Wallets 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 [Arc](https://www.arc.io/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Arc](https://www.arc.io/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.

## Chain details for Arc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Astar zkEVM Blockchain in Reac
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsAstarZkevm from '../../_general-connect-blockchain/_astar-zkevm.mdx'

While using the Embedded Wallets 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 [Astar zkEVM](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 quickly.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Astar zkEVM](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 quickly.

## Chain details for Astar zkEVM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Astar Zkyoto Blockchain in Rea
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsAstarZkyoto from '../../_general-connect-blockchain/_astar-zkyoto.mdx'

While using the Embedded Wallets 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 [Astar Zkyoto](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.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Astar Zkyoto](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.

## Chain details for Astar Zkyoto

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Avalanche Blockchain in React
import EVMInteraction from '../../_react-native-connect-blockchain/_evm-interaction.mdx'
import ChainDetailsAvalanche from '../../_general-connect-blockchain/_avalanche.mdx'

While using the Embedded Wallets 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 [Avalanche](https://www.avax.network/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.
While using the Embedded Wallets 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/). Use it with libraries such as [viem](https://viem.sh) or [ethers](https://docs.ethers.org/v6/) to make [Avalanche](https://www.avax.network/) blockchain calls like getting the user's `account`, fetching `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc.

## Chain details for Avalanche

Expand Down
Loading
Loading