1

I would like to use web3 inside the store as a Vuex plugin, so I can call this.web3 inside actions and mutations without having to pass the web3 instance from my components to the store. But since the store is compiled before web3 is injected, I'm wondering if it's even possible to write a plugin which could work like this.

I'm using Nuxt.js, by the way. So maybe there's something within Nuxt that would make this possible.

1 Answer 1

0

I had trouble using web3 as part of the vue instance (ie this.web3 = window.web3 caused errors). Instead I ended up moving all of my contract logic into a separate js file and including it in my store then accessing it as a getter. You can check out the method i used for the external js here and the vuex store here. maybe that implementation works for you.

otherwise there is a vue-cli repo for using truffle that integrates web3 inside of vuex here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.