npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-web3dapp

v0.1.4

Published

This Vue 3 plugin integrates Ethereum blockchain functionality into your Vue application using the Ethers.js library. It provides a `$web3` object that you can use within your components to interact with Ethereum wallets and smart contracts.

Downloads

14

Readme

Vue3 Web3 Plugin

This Vue 3 plugin integrates Ethereum blockchain functionality into your Vue application using the Ethers.js library. It provides a $web3 object that you can use within your components to interact with Ethereum wallets and smart contracts.

Installation

npm install your-vue3-web3-plugin

Usage

In your main.js:

import { createApp } from 'vue';
import App from './App.vue';
import store from './store'; // Ensure you have a Vuex store
import Web3Plugin from 'your-vue3-web3-plugin';

const app = createApp(App);

// Use the plugin
app.use(store).use(Web3Plugin, { store }).mount('#app');

In your components, you can access the $web3 methods as follows:

<script>
export default {
  mounted() {
    // Connect to the user's wallet
    this.$web3.connectWallet();
  },
  methods: {
    async getBalance() {
      const balance = await this.$web3.getBalance(this.$web3.address());
      console.log(balance);
    }
  }
};
</script>

$web3 Methods

  • $web3.address(): Returns the connected wallet address or null if not connected.
  • $web3.canConnect(): Checks if the current network is among the available networks specified in the options.
  • $web3.connectWallet(): Connects to the user's wallet and stores the address in the Vuex store.
  • $web3.contract(abi, address): Returns an ethers.js Contract instance to interact with a smart contract.
  • $web3.ERC20(address): Returns an ethers.js Contract instance pre-configured for an ERC20 token.
  • $web3.ERC721(address): Returns an ethers.js Contract instance pre-configured for an ERC721 token.
  • $web3.ERC1155(address): Returns an ethers.js Contract instance pre-configured for an ERC1155 token.
  • $web3.getBalance(address): Returns the balance of the given address.
  • $web3.getBlock(blockNumber): Returns the block details for the given block number.
  • $web3.getBlockNumber(): Returns the current block number.
  • $web3.getChainId(): Returns the current chain ID.
  • $web3.getGasPrice(): Returns the current gas price.
  • $web3.getNetwork(): Returns the network details.
  • $web3.getProvider(): Returns the connected provider, or false if no provider is connected.
  • $web3.getTransaction(transactionHash): Returns the transaction details for the given transaction hash.
  • $web3.getTransactionReceipt(transactionHash): Returns the transaction receipt for the given transaction hash.
  • $web3.isConnected(): Returns true if the wallet is connected, otherwise false.
  • $web3.multicall(): Returns a Multicall instance to batch multiple readonly calls.
  • $web3.toEth(wei, decimals): Converts Wei to Ether with the specified number of decimals.
  • $web3.toWei(eth, decimals): Converts Ether to Wei with the specified number of decimals.

Contributing

Please feel free to contribute to the development of this plugin by submitting issues or pull requests.

License

This project is licensed under the MIT License.


This README provides a brief overview of the plugin, how to install and use it, and a description of the `$web3` methods provided. Adjust the content as necessary to fit the specifics of your plugin and the methods it offers.