Skip to content

Commit 5a26eed

Browse files
committed
Update wallet-services-hooks.mdx
1 parent 0f01cc0 commit 5a26eed

1 file changed

Lines changed: 96 additions & 1 deletion

File tree

docs/sdk/wallet-services/wallet-services-hooks.mdx

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,102 @@ into it. For more details on the `Web3AuthProvider`, please refer to the
117117

118118
### Example Usage
119119

120-
```jsx
120+
```typescript title="web3AuthProviderProps.ts"
121+
import { Web3AuthContextConfig } from "@web3auth/modal-react-hooks";
122+
import { Web3AuthOptions } from "@web3auth/modal";
123+
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
124+
import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/base";
125+
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
126+
import { WalletServicesPlugin } from "@web3auth/wallet-services-plugin";
127+
128+
const chainConfig = {
129+
chainId: "0xaa36a7", // for wallet connect make sure to pass in this chain in the loginSettings of the adapter.
130+
displayName: "Ethereum Sepolia",
131+
chainNamespace: CHAIN_NAMESPACES.EIP155,
132+
tickerName: "Ethereum Sepolia",
133+
ticker: "ETH",
134+
rpcTarget: "https://rpc.ankr.com/eth_sepolia",
135+
blockExplorerUrl: "https://sepolia.etherscan.io",
136+
logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png",
137+
};
138+
139+
const privateKeyProvider = new EthereumPrivateKeyProvider({
140+
config: {
141+
chainConfig,
142+
},
143+
});
144+
145+
const web3AuthOptions: Web3AuthOptions = {
146+
clientId:
147+
"BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
148+
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
149+
uiConfig: {
150+
uxMode: "redirect",
151+
appName: "W3A Heroes",
152+
appUrl: "https://web3auth.io/",
153+
theme: {
154+
primary: "#7ed6df",
155+
},
156+
logoLight: "https://web3auth.io/images/web3authlog.png",
157+
logoDark: "https://web3auth.io/images/web3authlogodark.png",
158+
defaultLanguage: "en", // en, de, ja, ko, zh, es, fr, pt, nl, tr
159+
mode: "auto", // whether to enable dark mode. defaultValue: auto
160+
useLogoLoader: true,
161+
},
162+
privateKeyProvider: privateKeyProvider,
163+
sessionTime: 86400, // 1 day
164+
};
165+
166+
const openloginAdapter = new OpenloginAdapter({
167+
loginSettings: {
168+
mfaLevel: "optional",
169+
},
170+
adapterSettings: {
171+
uxMode: "redirect", // "redirect" | "popup"
172+
whiteLabel: {
173+
logoLight: "https://web3auth.io/images/web3authlog.png",
174+
logoDark: "https://web3auth.io/images/web3authlogodark.png",
175+
defaultLanguage: "en", // en, de, ja, ko, zh, es, fr, pt, nl, tr
176+
mode: "dark", // whether to enable dark, light or auto mode. defaultValue: auto [ system theme]
177+
},
178+
mfaSettings: {
179+
deviceShareFactor: {
180+
enable: true,
181+
priority: 1,
182+
mandatory: true,
183+
},
184+
backUpShareFactor: {
185+
enable: true,
186+
priority: 2,
187+
mandatory: false,
188+
},
189+
socialBackupFactor: {
190+
enable: true,
191+
priority: 3,
192+
mandatory: false,
193+
},
194+
passwordFactor: {
195+
enable: true,
196+
priority: 4,
197+
mandatory: true,
198+
},
199+
},
200+
},
201+
});
202+
203+
const walletServicesPlugin = new WalletServicesPlugin({
204+
wsEmbedOpts: {},
205+
walletInitOptions: { whiteLabel: { showWidgetButton: true } },
206+
});
207+
208+
export const web3AuthContextConfig: Web3AuthContextConfig = {
209+
web3AuthOptions,
210+
adapters: [openloginAdapter],
211+
plugins: [walletServicesPlugin],
212+
};
213+
```
214+
215+
```typescript title="App.tsx"
121216
import React from "react";
122217
import App from "./App";
123218
import { Web3AuthProvider, Web3AuthInnerContext } from "@web3auth/modal-react-hooks";

0 commit comments

Comments
 (0)