mirror of
https://github.com/arnaucube/reciproka.git
synced 2026-02-07 19:56:41 +01:00
first commit
This commit is contained in:
32
contracts/account.sol
Normal file
32
contracts/account.sol
Normal file
@@ -0,0 +1,32 @@
|
||||
pragma solidity ^0.4.23;
|
||||
|
||||
contract Accounts {
|
||||
|
||||
mapping(address => Account) accounts;
|
||||
|
||||
struct Account {
|
||||
address ID;
|
||||
int64 Balance;
|
||||
bytes32[] History;
|
||||
}
|
||||
|
||||
event BalanceUpdated(address sender, address receiver, int64 value);
|
||||
|
||||
function updateBalance(address _receiver, int64 _value) public {
|
||||
// get Account of _sender
|
||||
// check if balance of _sender is under the limit
|
||||
// substract _value from _sender account
|
||||
accounts[msg.sender].Balance = accounts[msg.sender].Balance - _value;
|
||||
// add _value to _receiver account
|
||||
accounts[_receiver].Balance = accounts[_receiver].Balance + _value;
|
||||
|
||||
// add transaction to history of sender and receiver accounts
|
||||
|
||||
// emit BalanceUpdated
|
||||
emit BalanceUpdated(msg.sender, _receiver, _value);
|
||||
|
||||
}
|
||||
function getBalance(address _address) public view returns (int64) {
|
||||
return accounts[_address].Balance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user