0

I am trying to send a notification to a user on some activity. I tried to use events but when an event is triggered, it goes to all the user accounts that are currently active on the network. Is there some other way to do the same thing in Ethereum.

2

No, there is not. Ethereum is a public ledger. That means a) everything you do is public, everyone sees everything you do. b) Everything is pull. If a user wants to see something, he can query the blockchain, you can not push something to a specific address.

Of course you could create something similar. But solutions like that would still be public and would depend on client-implementation. However, the whole idea of the blockchain is independence from central middlemen and client-implementation

If you want to implement something like it: Create a mapping that maps address -> your message in the contract. The client can then regularly check for updates in this mapping.

1

You can create topics in your logs by indexing specific fields in your event

event BidPlaced(address indexed bidder, uint amount);

You can then filter for these events by the indexed fields on your frontend and display only relevant notifications to the user

var contract = web3.eth.contract(abi).at(contractAddress);
contract.BidPlaced({ bidder: "0x0000..." }).get(console.log);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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