0.1.20 • Published 2 years ago

vagmi v0.1.20

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

0.1.20

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.0

2 years ago

0.1.16

2 years ago

0.1.8

2 years ago

0.1.17

2 years ago

0.1.7

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.0.2

2 years ago