Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. //Events
  2. event RequestReceived(bytes s);
  3. event WorldCreated(bytes32 indexed worldName, address indexed sender, address result );
  4.  
  5. function createWorld(bytes32 name) returns (World a){
  6. RequestReceived("createWorld fired");
  7.  
  8. World w = new World(name);
  9. worldContracts.push(w);
  10.  
  11. WorldCreated(name,msg.sender,w);
  12. return w;
  13. }
  14.  
  15. public static string CreateWorld(string world)
  16. {
  17.  
  18. var web3 = new Web3(Resources.Server);
  19. // Contract address
  20. var contract = web3.Eth.GetContract(Resources.ContractInterface2, address);
  21.  
  22. var add = contract.GetFunction("createWorld"); // Add method
  23. var worldCreatedEvent = contract.GetEvent("WorldCreated");
  24. var filterAll = worldCreatedEvent.CreateFilterAsync().Result;
  25. var totalGas = GenericUtil.GetGasPrice(add, world);
  26. UnlockAccountForTransaction();
  27. var callResult = add.SendTransactionAsync("0x13111c7C98dFb371A4dd6cD1B1D9E6285bE68d2e", totalGas, new HexBigInteger(0), world).Result;
  28. var theResult = GenericUtil.GetReceiptAsync(web3, callResult);
  29. var log = worldCreatedEvent.GetAllChanges<WorldCreatedEvent>(filterAll).Result;
  30.  
  31.  
  32. return log[0].Event.Result;
  33. }
  34.  
  35. var filterAll = worldCreatedEvent.CreateFilterAsync().Result;
  36.  
  37. var filterAll = worldCreatedEvent.CreateFilterAsync(world).Result;
  38.  
  39. debug.traceTransaction("0x....");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement