Interact
Connecting to Lumia chain with Web3 EVM Wallet Library
Connecting to Lumia chain with Web3-Onboard
Installation
yarn add @web3-onboard/core @web3-onboard/injected-wallets @web3-onboard/react ethersConfiguration
import React from "react";
import { init, useConnectWallet } from "@web3-onboard/react";
import injectedModule from "@web3-onboard/injected-wallets";
import { ethers } from "ethers";
const wallets = [injectedModule()];
const chains = [
{
id: "0x51",
token: "LOC",
label: "Lumia Testnet",
icon: '<svg>...</svg>',
color: "#2c3335",
rpcUrl: "https://testnet-rpc.lumia.org",
publicRpcUrl: "https://testnet-rpc.lumia.org",
blockExplorerUrl: "https://testnet-explorer.lumia.org/",
},
];
const appMetadata = {
name: "My Lumia L2 App",
icon: '<svg>...</svg>',
logo: '<svg>...</svg>',
description: "My app using Onboard on Lumia L2 Network",
recommendedInjectedWallets: [
{ name: "MetaMask", url: "https://metamask.io" },
],
};
init({
wallets,
chains,
appMetadata,
});
const [{ wallet, connecting }, connect, disconnect] = useConnectWallet();
let ethersProvider;
if (wallet) {
ethersProvider = new ethers.providers.Web3Provider(wallet.provider, "any");
}Usage
Last updated
Was this helpful?