Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. pragma solidity ^0.4.0;
  2. contract Ballot {
  3. pragma solidity ^0.4.23;
  4.  
  5. contract shop {
  6. struct user {
  7. int balance;
  8. address ip;
  9. }
  10.  
  11. struct tovar {
  12. string name;
  13. int cost;
  14. address seller;
  15. }
  16.  
  17. address kap;
  18. user[] users;
  19. tovar[] tovars;
  20.  
  21. function check_costumer(address _ip) private returns(bool){
  22. bool flag = 0;
  23. for (i := 0; i < users.length; i++) {
  24. if (usres[i].ip == _ip) {
  25. flag = 1;
  26. }
  27. }
  28. return flag;
  29. }
  30.  
  31. function init_user() public {
  32. bool flag = check_costumer(msg.sender);
  33. if (!flag) {
  34. users.length = users.length + 1;
  35. users[users.length - 1].ip = msg.sender;
  36. users[users.length - 1].balance = 10000;
  37. }
  38. else {
  39. //пользователь зареган - обработать
  40. }
  41. }
  42.  
  43. function add_tovar(string _name, int _cost) public {
  44. bool flag = check_costumer(msg.sender);
  45. tovars.length = tovars.length + 1;
  46. tovars[tovars.length - 1].name = _name;
  47. tovars[tovars.length - 1].cost = _cost;
  48. tovars[tovars.length - 1].seller = msg.sender;
  49. }
  50.  
  51. function bye_tovar(string _id) public {
  52. address buy = msg.sender;
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement