eth-vue icon indicating copy to clipboard operation
eth-vue copied to clipboard

Development issue

Open BeeSeeChain opened this issue 6 years ago • 3 comments

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?

BeeSeeChain avatar Aug 04 '18 18:08 BeeSeeChain

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 :)].

DOkwufulueze avatar Aug 05 '18 11:08 DOkwufulueze

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?

BeeSeeChain avatar Aug 05 '18 16:08 BeeSeeChain

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

DOkwufulueze avatar Nov 08 '20 16:11 DOkwufulueze