DOkwufulueze / eth-vue

Featured in Awesome Vue [https://github.com/vuejs/awesome-vue], a curated list maintained by vuejs of awesome things related to the Vue.js framework, and Awesome List [https://awesomelists.net/150-Vue.js/3863-Open+Source/18749-DOkwufulueze-eth-vue], this Truffle Box provides everything you need to quickly build Ethereum dApps that have authentication features with vue, including configuration for easy deployment to the Ropsten Network. It's also Gravatar-enabled. Connecting to a running Ganache blockchain network from Truffle is also possible -- for fast development and testing purposes. Built on Truffle 5 and Vue 3, eth-vue uses vuex for state management, vuex-persist for local storage of app state, and vue-router for routing. Authentication functionalities are handled by Smart Contracts running on the Ethereum blockchain.
GNU General Public License v3.0
243 stars 40 forks source link

Development issue #15

Open BeeSeeChain opened 6 years ago

BeeSeeChain commented 6 years ago

Hi, i'm using the amazing framework,but i couldn't to getting a event of solidity in VUE,for example: PlaygroudBattle.sol contract PlaygroundBattle is Destructible { address public dbAddress;

event won(bool status,uint amount);

}

The problem is: How should i to do for using "event won() " in DOkwufulueze/eth-vue framework in VUE?

DOkwufulueze commented 6 years ago

Hi, @BeeSeeChain

To have Solidity emit events that you can listen to on the dApp, you'll have to run the event within the relevant context. For example, using the event won that you declared in this issue (assuming amount is known), one would expect to see a method where the event is emitted thus:

    won(true, amount)

By running the event as stated above, Solidity emits the won event, which can easily be listened to outside the blockchain.

Let us know if this helps or not [hoping it'll help :)].

BeeSeeChain commented 6 years ago

Thanks for your reply but when i'm doing like this in Vue for listening event like this

      let playgroundBattleContractInstance = contract(PlaygroundBattleContractJSON)
      playgroundBattleContractInstance.setProvider(this.$store.state.web3.instance().currentProvider)
      let won = playgroundBattleContractInstance.won()
      won.watch((err, result) => {
        if (err) {
          console.log('could not get event won()')
        } else {
          this.winEvent = result.args
          this.pending = false
        }
      })

i will recived that error : Uncaught (in promise) TypeError: playgroundBattleContractInstance.won is not a function

so can i do for listening solidity event correctly in DOkwufulueze/eth-vue?how should i write the Code?

DOkwufulueze commented 4 years ago

@BeeSeeChain Could you check the logs to see how playgroundBattleContractInstance is structured? That should help you try to read its members correctly.