ERC23TokenMock.sol 858 B

123456789101112131415161718192021222324252627282930313233
  1. pragma solidity ^0.4.18;
  2. import '../token/BasicToken.sol';
  3. contract ERC23ContractInterface {
  4. function tokenFallback(address _from, uint256 _value, bytes _data) external;
  5. }
  6. contract ERC23TokenMock is BasicToken {
  7. function ERC23TokenMock(address initialAccount, uint256 initialBalance) public {
  8. balances[initialAccount] = initialBalance;
  9. totalSupply = initialBalance;
  10. }
  11. // ERC23 compatible transfer function (except the name)
  12. function transferERC23(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. ERC23ContractInterface receiver = ERC23ContractInterface(_to);
  22. receiver.tokenFallback(msg.sender, _value, _data);
  23. }
  24. return true;
  25. }
  26. }