Skip to content
forked from vu3th/vue-dapp

Vue 3 library for building Dapps on Ethereum.

License

Notifications You must be signed in to change notification settings

re2005/vue-dapp

 
 

Repository files navigation

VueDapp Brand

Vue Dapp

Vue 3 library for building Dapps on Ethereum.

MIT License Version Size

Documentation

Brief versions and functionalities are as follows:

  • v0.12.x: Add bitget wallet
  • v0.11.x: Uses ethers v5 with WalletConnect dependencies update.
  • v0.10.x: Uses ethers v6 and supports WalletConnect v2.
  • v0.9.x: Uses ethers v5 and supports WalletConnect v2.
  • Before v0.8.x: Uses ethers v5 and does not support WalletConnect v2.

I recommend keeping an eye on vue3-dapp-starter and nuxt-dapp, as it strives to maintain a development-friendly version whenever possible.

Please be cautious when using the documentation below, as it has not been updated for some time.

Packages

Package Description
@vue-dapp/core useWalletStore, connector, utils, and metamask...
@vue-dapp/vd-board Vue components for connecting wallet
@vue-dapp/walletconnect WalletConnect integration
@vue-dapp/legacy vue-dapp version below v1
@vue-dapp/docs documentation
@vue-dapp/app Nuxt 3 demo for v1
@vue-dapp/demo Vue 3 demo for @vue-dapp/legacy

Installation (below v0.10.x)

yarn add ethers vue-dapp

If you want to support more wallet providers not only MetaMask, you should install respective packages to enable the dynamic import.

  • Support WalletConnect
yarn add @walletconnect/web3-provider
  • Support Coinbase Wallet
yarn add @coinbase/wallet-sdk
  • Support Gnosis Safe
yarn add @gnosis.pm/safe-apps-provider @gnosis.pm/safe-apps-sdk

Quick Start

Step 1. Add plugin to your app:

import { VueDapp } from "vue-dapp";
const app = createApp(App);
app.use(VueDapp);
app.mount("#app");

Step 2. By default, VueDapp includes Mainnet and Goerli networks, but you can extend it to include other networks:

app.use(VueDapp, {
 autoConnect: true, // Automatically connect MetaMask wallet when the page is loaded
  networks: {
    80001: {
      chainId: ethers.utils.hexValue(80001),
      blockExplorerUrls: ['https://mumbai.polygonscan.com/'],
      chainName: 'Mumbai',
      rpcUrls: ['https://rpc-mumbai.maticvigil.com/'],
      nativeCurrency: {
        name: 'Mumbai',
        decimals: 18,
        symbol: 'MATIC',
      },
    },
    42161: {
      ...
    },
  },
});

For more examples please check: https://github.com/wagmi-dev/wagmi/blob/main/packages/core/src/constants/chains.ts

Step 3. Add <vd-board /> to your App.vue and add a button to open the board:

<button @click="open">Connect Wallet</button>
<vd-board :connectors="connectors" dark />

Step 4. Construct your connectors and use composable functions in your scripts:

import {
  MetaMaskConnector,
  WalletConnectConnector,
  CoinbaseWalletConnector,
  useBoard,
} from "vue-dapp";

setup() {
  const { open } = useBoard();
  const infuraId = "";
  const connectors = [
    new MetaMaskConnector({
      appUrl: "http://localhost:3000",
    }),
    new WalletConnectConnector({
      qrcode: true,
      rpc: {
        1: `https://mainnet.infura.io/v3/${infuraId}`,
        4: `https://rinkeby.infura.io/v3/${infuraId}`,
      },
    }),
    new CoinbaseWalletConnector({
      appName: "Vue Dapp",
      jsonRpcUrl: `https://mainnet.infura.io/v3/${infuraId}`,
    }),
  ];
  return {
    connectors,
    open,
  };
}

Take a look at Configurations for more informations about Vue CLI, Vite, and Nuxt3 configurations.

To see the demo code, check it out here.

Support 🙏

Gitcoin Grants 18: https://explorer.gitcoin.co/#/round/10/0x8de918f0163b2021839a8d84954dd7e8e151326d/0x8de918f0163b2021839a8d84954dd7e8e151326d-43

MIT license

Copyright (c) 2021-present, Johnson Chen (@chnejohnson)

About

Vue 3 library for building Dapps on Ethereum.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 69.8%
  • Vue 27.2%
  • JavaScript 1.9%
  • SCSS 0.9%
  • HTML 0.2%
  • Shell 0.0%