Saltar al contenido principal

Integrating WalletConnect with Vue.js Project on Conflux eSpace

This tutorial guides you through the process of integrating WalletConnect with Web3Modal in a Vue.js project, specifically targeting the Conflux eSpace network. For a hands-on example, check out the GitHub repository Web3modal-Conflux-Vue.

Vue Demo


  • Node.js installed on your computer.
  • Basic knowledge of Vue.js and JavaScript.

Step 1: Setting Up Your Vue.js Project

First, create a new Vue.js project using Vite, you can skip this step if you have an existing project. Open your terminal and run the following commands:

npm create vite@latest web3modal-conflux-vue -- --template vue
cd web3modal-conflux-vue
npm install

Step 2: Install Web3Modal and WalletConnect

You need to install Web3Modal and the WalletConnect provider. Run:

npm install @web3modal/wagmi @wagmi/core @wagmi/connectors viem

Step 3: Setting Up Web3Modal

Create a new file named Web3ModalSetup.js in your project's src directory, and import the necessary modules to set up WalletConnect.

import { createWeb3Modal } from "@web3modal/wagmi/vue";

import { reconnect, http, createConfig } from "@wagmi/core";
import { confluxESpace } from "@wagmi/core/chains";
import { walletConnect, injected } from "@wagmi/connectors";

// 1. Define constants
const projectId = "YOUR_PROJECT_ID";
const metadata = {
name: "Web3Modal",
description: "Web3Modal Example",
url: "", // origin must match your domain & subdomain
icons: [""],

const config = createConfig({
chains: [confluxESpace],
transports: {
[]: http(),
connectors: [
walletConnect({ projectId, metadata, showQrModal: false }),
injected({ shimDisconnect: true }),

// 3. Create modal
wagmiConfig: config,
enableAnalytics: true, // Optional - defaults to your Cloud configuration
enableOnramp: true, // Optional - false as default

Replace "YOUR_PROJECT_ID" with your actual project ID.

For details on how to obtain ProjectId, please refer to this article.

Make sure that the url from the metadata matches your domain and subdomain. This will later be used by the Verify API to tell wallets if your application has been verified or not.

Step 4: Using Web3ModalSetup in your Application

In your App.vue, import the web3ModalSetup instance and use it to connect to the wallet. Here’s how you can do it in your App.vue:

<script setup>
import HelloWorld from "./components/HelloWorld.vue";
import "./web3ModalSetup";

<a href="" target="_blank">
alt="WalletConnect Logo"
<a href="" target="_blank">
<img src="./assets/conflux-logo.svg" class="logo vue" alt="Conflux Logo" />
<HelloWorld msg="WalletConnect + Conflux" />


Step 5: Connecting Conflux eSpace Network

Create a new component, ConnectWallet.vue, in your project, to open ConnectWallet Modal

<button @click="">Open Connect Modal</button>

<script setup>
import { useWeb3Modal } from "@web3modal/wagmi/vue";
// 4. Use modal composable
const modal = useWeb3Modal();

<style lang="scss" scoped>

In HelloWorld.vue or any other component, use the ConnectWallet component to connect to wallets on the Conflux eSpace

<script setup>
import { ref } from "vue";

import ConnectWallet from "./ConnectWallet.vue";

msg: String,
const count = ref(0);

<h1>{{ msg }}</h1>

<div class="card">
<ConnectWallet />
<p>Using Web3Modal on Conflux eSpace Dapp</p>

<p class="read-the-docs">
Click on the WalletConnect and Conflux logos to learn more

<style scoped>
.read-the-docs {
color: #888;

You now have a basic setup for integrating Web3Modal with WalletConnect in your Vue.js project using Vite. This setup allows users to connect their wallets from a Vue.js application, enabling interactions with Conflux eSpace.