I have a token exchange (Contract A) and another contract (Contract B) that already can accept tokens and run logic when it receives tokens. Now I want to know how I can send tokens to the contract which does not run logic. Instead it should only increase the contracts (B) token balance. And how does the contract know about how many tokens it (B) has when i just send tokens to?
This is the current structure:
contract A {
/**
* Transfer token to a specified address and forward the data to recipient
* ERC-677 standard
* https://github.com/ethereum/EIPs/issues/677
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transferAndCall(address _to, uint256 _value, bytes _data)
external
returns (bool)
{
require(_to != address(0));
require(canAcceptTokens_[_to] == true); // security check that contract approved by the platform
require(transfer(_to, _value)); // do a normal token transfer to the contract
if (isContract(_to)) {
B receiver = B(_to);
require(receiver.tokenFallback(msg.sender, _value, _data));
}
return true;
}
}
contract B {
/**
* @dev Standard ERC677 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint256 _value, bytes _data)
onlyTokenContract()
external
returns (bool)
{
// allocate tokens
tokenBalanceLedger_[_from] = SafeMath.add(tokenBalanceLedger_[_from], _value);
tokenSupply_ = SafeMath.add(tokenSupply_, _value);
return true;
}
}