You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
894 B

6 years ago
  1. pragma solidity ^0.4.23;
  2. contract Accounts {
  3. mapping(address => Account) accounts;
  4. struct Account {
  5. address ID;
  6. int64 Balance;
  7. bytes32[] History;
  8. }
  9. event BalanceUpdated(address sender, address receiver, int64 value);
  10. function updateBalance(address _receiver, int64 _value) public {
  11. // get Account of _sender
  12. // check if balance of _sender is under the limit
  13. // substract _value from _sender account
  14. accounts[msg.sender].Balance = accounts[msg.sender].Balance - _value;
  15. // add _value to _receiver account
  16. accounts[_receiver].Balance = accounts[_receiver].Balance + _value;
  17. // add transaction to history of sender and receiver accounts
  18. // emit BalanceUpdated
  19. emit BalanceUpdated(msg.sender, _receiver, _value);
  20. }
  21. function getBalance(address _address) public view returns (int64) {
  22. return accounts[_address].Balance;
  23. }
  24. }