Coder Social home page Coder Social logo

renzhou-r / vue-dapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vu3th/vue-dapp

0.0 0.0 0.0 1.11 MB

Vue 3 library for building Dapps on Ethereum.

Home Page: https://vuedapp.vercel.app/

License: MIT License

Shell 0.08% JavaScript 3.20% TypeScript 77.76% Vue 18.96%

vue-dapp's Introduction

VueDapp Brand

Vue Dapp

Vue 3 library for building Dapps on Ethereum.

MIT License Version Size

Documentation

Installation

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: https://gitcoin.co/grants/3987/vue-dapp

MIT license

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

vue-dapp's People

Contributors

johnson86tw avatar re2005 avatar semantic-release-bot avatar kjpou1 avatar coxlr avatar mulander-j avatar bizordec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.