Learn how to set up popular Web3 libraries with Para on React Native. Choose from or to build your EVM application.
Wagmi is not available on React Native. Use Ethers.js or Viem for EVM operations.
Prerequisites
Before setting up Web3 libraries, you need an authenticated Para session.
Installation
npm install @getpara/ethers-v6-integration ethers@^6 --save-exact
npm install @getpara/viem-v2-integration viem@^2 --save-exact
Library Setup and Configuration
Configure your chosen Web3 library. You can use either a hook-based approach for React Native applications or a direct client setup if you want to access the client outside of the ParaProvider context.
import { useClient, useAccount } from "@getpara/react-native-wallet";
import { ParaEthersSigner } from "@getpara/ethers-v6-integration";
import { ethers } from "ethers";
import { useMemo } from "react";
export function useEthers(rpcUrl: string = "https://ethereum-sepolia-rpc.publicnode.com") {
const para = useClient();
const { isConnected } = useAccount();
return useMemo(() => {
const provider = new ethers.JsonRpcProvider(rpcUrl);
if (!para || !isConnected) {
return { provider, signer: null };
}
const signer = new ParaEthersSigner(para, provider);
return { provider, signer };
}, [para, isConnected, rpcUrl]);
}
import { useClient, useAccount } from "@getpara/react-native-wallet";
import { createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
import { createPublicClient, http } from "viem";
import { sepolia } from "viem/chains";
import { useMemo, useEffect, useState } from "react";
export function useViem(rpcUrl: string = "https://ethereum-sepolia-rpc.publicnode.com") {
const para = useClient();
const { isConnected } = useAccount();
const [walletClient, setWalletClient] = useState(null);
const publicClient = useMemo(() => createPublicClient({
chain: sepolia,
transport: http(rpcUrl)
}), [rpcUrl]);
useEffect(() => {
if (!para || !isConnected) {
setWalletClient(null);
return;
}
createParaAccount(para).then(account => {
const client = createParaViemClient(para, {
account,
chain: sepolia,
transport: http(rpcUrl)
});
setWalletClient(client);
});
}, [para, isConnected, rpcUrl]);
return { publicClient, walletClient };
}
import { ParaEthersSigner } from "@getpara/ethers-v6-integration";
import { ethers } from "ethers";
import Para from "@getpara/core-sdk";
const PARA_API_KEY = "YOUR_PARA_API_KEY";
export async function setupEthers(rpcUrl: string = "https://ethereum-sepolia-rpc.publicnode.com") {
const para = new Para(PARA_API_KEY);
const provider = new ethers.JsonRpcProvider(rpcUrl);
const isAuthenticated = await para.isSessionActive();
if (!isAuthenticated) {
throw new Error("Para session not authenticated");
}
const wallets = await para.getWalletsByType({ type: "EVM" });
if (wallets.length === 0) {
throw new Error("No EVM wallets available");
}
const signer = new ParaEthersSigner(para, provider);
return { provider, signer, para };
}
import { createParaViemClient, createParaAccount } from "@getpara/viem-v2-integration";
import { createPublicClient, http } from "viem";
import { sepolia } from "viem/chains";
import Para from "@getpara/core-sdk";
const PARA_API_KEY = "YOUR_PARA_API_KEY";
export async function setupViem(chain = sepolia, rpcUrl: string = "https://ethereum-sepolia-rpc.publicnode.com") {
const para = new Para(PARA_API_KEY);
const publicClient = createPublicClient({
chain,
transport: http(rpcUrl)
});
const isAuthenticated = await para.isSessionActive();
if (!isAuthenticated) {
throw new Error("Para session not authenticated");
}
const wallets = await para.getWalletsByType({ type: "EVM" });
if (wallets.length === 0) {
throw new Error("No EVM wallets available");
}
const account = await createParaAccount(para);
const walletClient = createParaViemClient(para, {
account,
chain,
transport: http(rpcUrl)
});
return { publicClient, walletClient, para };
}
Next Steps
Now that you have Web3 libraries configured with Para, explore common operations.