0

I am implementing a ERC223 token.I successfully deployed ERC223 token on local block-chain network block-chain.

transfer function solidity code is:-

function transfer(address _to, uint _value, bytes _data) {
        // Standard function transfer similar to ERC20 transfer with no _data .
        // Added due to backwards compatibility reasons .
        uint codeLength;

    assembly {
        // Retrieve the size of the code on target address, this needs assembly .
        codeLength := extcodesize(_to)
    }

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    if(codeLength>0) {
        ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
        receiver.tokenFallback(msg.sender, _value, _data);
    }
    emit Transfer(msg.sender, _to, _value, _data);
}


function transfer(address _to, uint _value) {
    uint codeLength;
    bytes memory empty;

    assembly {
        // Retrieve the size of the code on target address, this needs assembly .
        codeLength := extcodesize(_to)
    }

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    if(codeLength>0) {
        ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
        receiver.tokenFallback(msg.sender, _value, empty);
    }
    emit Transfer(msg.sender, _to, _value, empty);
}

One thing I can not understand.What value I passed in transfer function arguments. when I checked my ERC223 token working correctly or not??

1.What should be address _to value in transfer function?

2.What should be uint _value in transfer function?

3.What should be bytes data in transfer function?

4.what params should be given in place of _data?

  • Have you ever found an answer? – Andrey Jun 18 '18 at 16:49
1
1.What should be address _to value in transfer function?

Sender will send tokens to whom/what? Type: address.

2.What should be uint _value in transfer function?

Sender will how many tokens to receiver? Type: uint.

3.What should be bytes data in transfer function?

This is not an argument in the transfer function. Where do you see that?

4.what params should be given in place of _data?

If the receiver is a contract it may have a tokenFallback function to run when these tokens are received. _data will send arbitrary information to this function, the meaning of which will be on a case-by-case basis. This is your opportunity to implement application-specific logic without breaking the standard.

This argument is optional. It's passed through with this line:

receiver.tokenFallback(msg.sender, _value, _data);

Note that are two implementations of transfer. Each transaction will run one or the other depending on the number of arguments passed. That is, with or without the optional bytes _data.

Hope it helps.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.