nuxt-web3

0.0.8ย โ€ขย Publicย โ€ขย Published

nuxt-web3

npm version npm downloads License

Web3.js module integration for Nuxt

Setup

  1. Add nuxt-web3 dependency to your project
yarn add nuxt-web3 # or npm i nuxt-web3
  1. Add nuxt-web3 to the modules section of nuxt.config.js
{
  modules: [
    "nuxt-web3",
  ];
}

Or

modules: [
  "nuxt-web3",
  // Or
  [
    "nuxt-web3",
    {
      /* module options */
    }
  ]
];

Module Options

// nuxt.config.js
export default {
  modules: ["nuxt-web3"],
  //....
  web3: {
    provider: "" // Used as fallback if no runtime config is provided
  },

  publicRuntimeConfig: {
    web3: {
      provider: process.env.WEB3_PROVIDER_URL
    }
  },

  privateRuntimeConfig: {
    web3: {
      provider: process.env.PROVIDER_URL
    }
  }
};

Usage

Using default ethereum window supported by the browsers :

window.web3 = new this.$Web3(ethereum);
//or
window.web3 = new this.$Web3(window.ethereum);

Using configuration or custom provider from nuxt.config.js.

window.web3 = new this.$web3;

Example Usage

Readme

Keywords

none

Package Sidebar

Install

npm i nuxt-web3

Weekly Downloads

22

Version

0.0.8

License

MIT

Unpacked Size

5.66 kB

Total Files

6

Last publish

Collaborators

  • developerfauzan