Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.0;
- contract Ballot {
- pragma solidity ^0.4.23;
- contract shop {
- struct user {
- int balance;
- address ip;
- }
- struct tovar {
- string name;
- int cost;
- address seller;
- }
- address kap;
- user[] users;
- tovar[] tovars;
- function check_costumer(address _ip) private returns(bool){
- bool flag = 0;
- for (i := 0; i < users.length; i++) {
- if (usres[i].ip == _ip) {
- flag = 1;
- }
- }
- return flag;
- }
- function init_user() public {
- bool flag = check_costumer(msg.sender);
- if (!flag) {
- users.length = users.length + 1;
- users[users.length - 1].ip = msg.sender;
- users[users.length - 1].balance = 10000;
- }
- else {
- //пользователь зареган - обработать
- }
- }
- function add_tovar(string _name, int _cost) public {
- bool flag = check_costumer(msg.sender);
- tovars.length = tovars.length + 1;
- tovars[tovars.length - 1].name = _name;
- tovars[tovars.length - 1].cost = _cost;
- tovars[tovars.length - 1].seller = msg.sender;
- }
- function bye_tovar(string _id) public {
- address buy = msg.sender;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement