Giter VIP home page Giter VIP logo

vagmi's Introduction

vagmi

npm (tag) npm bundle size NPM

Vue Composables for Ethereum

Features

  • ๐Ÿš€ Composables for working with wallets, ENS, contracts, transactions, signing, etc.
  • ๐Ÿ’ผ Built-in wallet connectors for MetaMask, WalletConnect, Coinbase Wallet, and Injected
  • ๐Ÿ‘Ÿ Caching, request deduplication, multicall, batching, and persistence
  • ๐ŸŒ€ Auto-refresh data on wallet, block, and network changes
  • ๐Ÿฆ„ TypeScript ready
  • ๐ŸŒณ [WIP] Test suite running against forked Ethereum network

...and a lot more.

Documentation

For full documentation and examples, visit vagmi.vercel.app.

Installation

Install vagmi and its ethers peer dependency.

npm install vagmi ethers

Quick Start

Connect a wallet in under 60 seconds.

import { VagmiPlugin, createClient } from 'vagmi';
import { getDefaultProvider } from 'ethers';
import App from './App.vue';

const client = createClient({
  autoConnect: true,
  provider: getDefaultProvider(),
});

const app = createApp(App);
app.use(VagmiPlugin(client));
app.mount('#app');
<script setup>
import { useAccount, useConnect, useDisconnect } from 'vagmi'
import { InjectedConnector } from 'vagmi/connectors/injected'

const { address, isConnected } = useAccount()
const { connect } = useConnect({
  connector: new InjectedConnector(),
})
const { disconnect } = useDisconnect()
</script>

<template>
  <div v-if="isConnected">
    Connected to {{ address }}
    <button @click="disconnect">Disconnect</button>
  </div>
  <button v-else @click="connect">
    Connect Wallet
  </button>
</template>

In this example, we create a vagmi Client and pass it to the VagmiPlugin Vue plugin. The client is set up to use the ethers Default Provider and automatically connect to previously connected wallets.

Next, we use the useConnect composable to connect an injected wallet (e.g. MetaMask) to the app. Finally, we show the connected account's address with useAccount and allow them to disconnect with useDisconnect.

We've only scratched the surface for what you can do with vagmi!

Credits

License

MIT

vagmi's People

Contributors

wobsoriano avatar murongg avatar loktarjugg avatar jewelsonn avatar reslear avatar omahs 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.