Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (35 sloc) 1.16 KB
pragma solidity ^0.5;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./ERC_223_Receiver.sol";
import "./ERC_223.sol";
contract VIM_API_Payments {
using SafeMath for uint256;
address _bank;
address constant _vimTokenAddr = 0x543920CD78B0d230C4c7ad849F4f32e03FB3DcA0;
mapping(address => uint256) public _balances;
event Payment(address sender, uint256 amount);
constructor() public {
_bank = msg.sender;
}
modifier onlyBank {
require(msg.sender == _bank, "Unauthorized");
_;
}
function tokenFallback(
address from,
uint256 value
) public returns (bool) {
ERC223 token = ERC223(msg.sender);
require(msg.sender == _vimTokenAddr, "Invalid VIM token");
require(token.transfer(_bank, value), "Error transfering funds.");
_balances[from] = _balances[from].add(value);
return true;
}
function balanceOf(address account) public view returns (uint256 balance) {
return _balances[account];
}
function upgradeBank(address addr) public onlyBank returns (bool success) {
_bank = addr;
return true;
}
}