I've seen other similar questions but I can't seem to pinpoint the error

In my contract

contract Authentication is Killable {

  event FriendEvent (bytes32 name, bytes32 handle);

   function login() constant
   returns (bytes32 n, bytes32 h) {
      FriendEvent(users[msg.sender].name, users[msg.sender].handle);
      return ("wtf", users[msg.sender].handle);

and then I'm calling the event in my code

 var authenticationInstance

 // Get current ethereum wallet.
 web3.eth.getCoinbase((error, coinbase) => {
    // Log errors, if any.
    if (error) {

    authentication.deployed().then(function(instance) {
      authenticationInstance = instance

      var exampleEvent = authenticationInstance.FriendEvent({_from: web3.eth.coinbase}, {fromBlock: 0, toBlock: 'latest'});

      //Call Watch on event
      exampleEvent.watch(function(err, result) {
        console.log("----------EXAMPLE EVENT");
        if (err) {


      // Attempt to login user - calling the login function
      authenticationInstance.login({from: coinbase})
      .then(function(result) {

The login function executes fine, but "----------EXAMPLE EVENT" isn't printing to console. I've also added fromBlock, toBlock like suggested in another post


The function is marked constant which means it can't alter the contract state on the chain, which means the event is never written to the chain, which means the event will never arrive.

Remove constant (and don't use .call() on the JS side). The client will receive a transaction receipt for the submitted transaction.

Wait the event to arrive.

Hope it helps.

  • omg thanks lifesaver <3 spent lots of time on this issue D: Dec 27 '17 at 4:11

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.