I have a function in one contract that looks like this:
//Events
event RequestReceived(bytes s);
event WorldCreated(bytes32 indexed worldName, address indexed sender, address result );
function createWorld(bytes32 name) returns (World a){
RequestReceived("createWorld fired");
World w = new World(name);
worldContracts.push(w);
WorldCreated(name,msg.sender,w);
return w;
}
Its purpose is to instantiate and store a reference to a contract called 'World' This is a POC game I am making where the gameworld, players and items etc exist purely within the blockchain.
I then invoke this from C# via Nethereum via:
public static string CreateWorld(string world)
{
var web3 = new Web3(Resources.Server);
// Contract address
var contract = web3.Eth.GetContract(Resources.ContractInterface2, address);
var add = contract.GetFunction("createWorld"); // Add method
var worldCreatedEvent = contract.GetEvent("WorldCreated");
var filterAll = worldCreatedEvent.CreateFilterAsync().Result;
var totalGas = GenericUtil.GetGasPrice(add, world);
UnlockAccountForTransaction();
var callResult = add.SendTransactionAsync("0x13111c7C98dFb371A4dd6cD1B1D9E6285bE68d2e", totalGas, new HexBigInteger(0), world).Result;
var theResult = GenericUtil.GetReceiptAsync(web3, callResult);
var log = worldCreatedEvent.GetAllChanges<WorldCreatedEvent>(filterAll).Result;
return log[0].Event.Result;
}
However, when I watch the contract that fires these events - I can see the RequestReceived and WorldCreated events appear in Mist/Ethereum Wallet - but when I run the C# code - it always detects 0 log entries.
I've tried changing filterAll to
var filterAll = worldCreatedEvent.CreateFilterAsync().Result;
and
var filterAll = worldCreatedEvent.CreateFilterAsync(world).Result;
Bot result in 0 log entries for the event
Note - Ether for gas shouldn't be a problem here- as I am on a private network and have plenty, I am actually supplying double the estimate from the GetGasPrice function.
I am also able to see in the WorldCreated Event in mist that the result is a valid contract address - so a World was created. I am able to do
debug.traceTransaction("0x....");
in geth to see that the transaction ended on a return statement - presumably the return w; (Granted, the debug.traceTransaction had about 516 operations being carried out, but it still ended with a good load of gas left in the engine.)
Does anyone have any idea why nethereum is unable to retrieve these events even though they are being fired in geth and visible in mist?