Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using Neo.SmartContract.Framework;
  2. using Neo.SmartContract.Framework.Services.Neo;
  3. using System;
  4. using System.Text;
  5. using System.Numerics;
  6.  
  7. namespace Neo.SmartContract
  8. {
  9. public class Contract1 : Framework.SmartContract
  10. {
  11. public static object Main(string operation, params object[] args)
  12. {
  13. /* params:
  14. * args[0] = key
  15. * args[1] = value
  16. */
  17. Runtime.Log("Contract executed");
  18. switch (operation)
  19. {
  20. case "storeSwitch":
  21. Runtime.Log("Case storeSwitch");
  22. Store((string)args[0], (string)args[1]);
  23. return true;
  24. case "store":
  25. //this code works
  26. Runtime.Log("Case Store setted");
  27. Runtime.Notify("args", args.Length);
  28. Storage.Put(Storage.CurrentContext, (string)args[0], (string)args[1]);
  29. Runtime.Log("Store executed");
  30. return true;
  31.  
  32. case "get":
  33. Runtime.Log("Case Get setted");
  34. return Get((string)args[0]);
  35.  
  36. default:
  37. Runtime.Log("Case DEFAULT setted");
  38. return false;
  39. }
  40.  
  41.  
  42.  
  43. }
  44. public static bool Store(string key, string value)
  45. {
  46. // If I call that from the switch case, it doesnt work.
  47. Runtime.Log("Inside Store operation");
  48. Storage.Put(Storage.CurrentContext, key, value);
  49. Runtime.Log("Store executed");
  50. return true;
  51. }
  52.  
  53. public static byte[] Get(string key)
  54. {
  55. // with this it happen the same, it doesnt work.
  56. Runtime.Log("Inside Get operation");
  57. return Storage.Get(Storage.CurrentContext, key);
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement