ERC223TokenMock.sol 871 B

12345678910111213141516171819202122232425262728293031
  1. pragma solidity ^0.4.18;
  2. import "../token/ERC20/BasicToken.sol";
  3. contract ERC223ContractInterface {
  4. function tokenFallback(address _from, uint256 _value, bytes _data) external;
  5. }
  6. contract ERC223TokenMock is BasicToken {
  7. function ERC223TokenMock(address initialAccount, uint256 initialBalance) public {
  8. balances[initialAccount] = initialBalance;
  9. totalSupply_ = initialBalance;
  10. }
  11. // ERC223 compatible transfer function (except the name)
  12. function transferERC223(address _to, uint256 _value, bytes _data) public
  13. returns (bool success)
  14. {
  15. transfer(_to, _value);
  16. bool is_contract = false;
  17. assembly {
  18. is_contract := not(iszero(extcodesize(_to)))
  19. }
  20. if (is_contract) {
  21. ERC223ContractInterface receiver = ERC223ContractInterface(_to);
  22. receiver.tokenFallback(msg.sender, _value, _data);
  23. }
  24. return true;
  25. }
  26. }