Solidity

Solidity

Kirill Lubimov

pragma solidity ^0.4.18;

contract First{

   struct MyStruct{

       address name;

       int value;

   }

   

   address owner;

   mapping (bytes32 => MyStruct) dict;

   int amount;

   string constant AUTHOR = "Lubimov Kirill";

   

   function First(){

       owner = msg.sender;

   }

   

   function getAuthorName() constant returns(string){

       return AUTHOR;

   }

   

   //function addItem(string key, address inputName, int inputValue){

   //   require(msg.sender == owner);

   //   dict[sha3(key)] = MyStruct({name: inputName, value: inputValue});

   //   amount += inputValue;

   //}

   

   function setAmount(int inputAmount){

       require(msg.sender == owner);

       amount = inputAmount;

   }

   

   function deleteItem(string key){

       require(msg.sender == owner);

       delete dict[sha3(key)];

   }

   

   function getAmount() constant returns(int){

       return amount;

   }

   

   function sellConttact(address newOwner, int inputValue){

       require(msg.sender == owner);

       dict[sha3(newOwner)]= MyStruct({name:newOwner, value: inputValue});

       owner = newOwner;

       amount += inputValue;

   }

}

Report Page