I am trying to listen to an event on rinkeby test which I run locally. Every thing works fine when my argument is int such as event EventTester(int values);
When I change the event argument to string (it is not indexed) it does not work and I do not see the log. event EventTester(string values);
. Any idea why? I do not see the Events Log tab when I check the transaction on https://rinkeby.etherscan.io.
Thanks
var fs = require('fs');
var Web3 = require('web3');
var util = require('ethereumjs-util');
var tx = require('ethereumjs-tx');
var lightwallet = require('eth-lightwallet');
var txutils = lightwallet.txutils;
var web3 = new Web3(
new Web3.providers.HttpProvider('http://localhost:8545')
);
var address = '0x.....';
var key = '';
var bytecode = '6060...90029';
var interface = [{"constant":false,"inputs":[{"name":"input","type":"string"}],"name":"getOut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"values","type":"string"}],"name":"EventTester","type":"event"}]
function sendRaw(rawTx) {
var privateKey = new Buffer(key, 'hex');
var transaction = new tx(rawTx);
transaction.sign(privateKey);
var serializedTx = transaction.serialize().toString('hex');
web3.eth.sendRawTransaction(
'0x' + serializedTx, function(err, result) {
if(err) {
console.log("ERROR HAPPENED:" +err);
}
});
}
var contractAddress = '0x...';
strInterface='[{"constant":false,"inputs":[{"name":"input","type":"string"}],"name":"getOut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"values","type":"string"}],"name":"EventTester","type":"event"}]'
abiDefinition = JSON.parse(strInterface)
myContract = web3.eth.contract(abiDefinition)
var contractInstance = myContract.at(contractAddress)
var txOptions = {
nonce: web3.toHex(web3.eth.getTransactionCount(address)),
gasLimit: web3.toHex(700000),
gasPrice: web3.toHex(10000000000),
to: contractAddress
};
var rawTx = txutils.functionTx(interface, 'getOut', ["hi"], txOptions);
sendRaw(rawTx);
pragma solidity ^0.4.0; contract SimpleContract { event EventTester(string values); mapping(address => uint) callers; function SimpleContract() public{} function getOut(string input) public { EventTester(input); callers[msg.sender] +=1; } }
The listener isevent.watch(function(error, result){ if (!error){ console.log(result); }else { console.log('Error happened') } });
If you change string to int everything works well.