Search code examples
ethereumweb3jstruffle

How to show event at frontend


I could successfully emitted event, but I don't know how to show those event.

My event is this

  event Sell (
    address indexed _buyer, 
    uint256 indexed _value
  );

I could get all event in console.

const event = await tokenSale.events.Sell({}, {
  fromBlock: 0,
  toBlock: 'latest',
})
event.on("data", (data) => console.log("data", data))

I want to show _value in frontend.

Could you give me any advise, please?


Solution

  • There are lots of ways to render values in the front end. It depends on what language/library you are using. If you are using React, a nice tool for passing contract data to the front end is Drizzle