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.
-
1As far as I am aware this isnt usable yet but I think whisper github.com/ethereum/wiki/wiki/Whisper is what you are looking for – Joe Mar 20 '17 at 13:20
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.
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);