I am trying to get balanceof an address but i dont know what i should input for address token. I looked at some other answers. One answer said the tokens send to address(0) is burn. What does that mean? Does it mean no one receive the tokens?

function deposit() payable {
tokens[address(0)][msg.sender] = safeAdd(tokens[address(0)][msg.sender], msg.value);
lastActiveTransaction[msg.sender] = block.number;
Deposit(address(0), msg.sender, msg.value, tokens[address(0)][msg.sender]);

function balanceOf(address token, address user) constant returns (uint256) {
return tokens[token][user];

2 Answers 2


address(0) is a short way to write 0x0000000000000000000000000000000000000000 (which is essentially 0x0). The address is sometimes used to burn tokens, since it's very unlikely that someone has the private key for this address.

The deposit function in your code assigns an amount of ETH (msg.value) to tokens[0x0][sender address], it does not actually send any ETH or tokens.

  • The code is from IDEX contract. I am trying to understand the contract. So the deposit function does not do anything?
    – chen Crush
    Jun 17, 2020 at 20:42
  • Whenever you send ETH to the contract and call the deposit function, it will assign that ETH to you in the tokens array, with address(0) as token address. It likely uses this address since it's not an actual token and reserved for ETH deposits.
    – Morten
    Jun 18, 2020 at 8:29

address(0) is a conceptual-abbreviation of an address with no known private key.

Naturally, it means that if you transfer your ether to this address, then no one will be able to retrieve it.

If you transfer your tokens to this address... well, that depends on how the token contract is implemented.

For example, this promiscuous contract will allow anyone to retrieve them:

contract ERC20Token {
    mapping (address => uint256) public balanceOf;

    function transfer(address _to, uint256 _value) public returns (bool) {
        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;
        return true;

    function retrieve() public returns (bool) {
        balanceOf[msg.sender] += balanceOf[address(0)];
        balanceOf[address(0)] = 0;
        return true;

Conventional token contracts, however, do not provide such functionality, so transferring your tokens to address(0) is similar to transferring your ether to this address, in the sense that no one will be able to retrieve them.

One answer said the tokens send to address(0) is burn

That really depends on how you define (choose to implement) burn.

The ERC20 standard doesn't say anything about this, but usually, burning an amount of tokens only means that you subtract that amount from the balanceOf some address, and unlike transfer, you don't add it to the balanceOf of any other address.

In addition to that, the burn function also subtracts that amount from totalSupply.

But under no circumstances do you transfer those tokens to address(0), since it is pointless.

If you did transfer them to address(0), then it wouldn't be right to subtract that amount from totalSupply, and subsequently, it wouldn't be right to refer to that action as burn.

One point worth noting, is that when burning tokens, it is custom for the burn function in the token contract to emit an ERC20-standard Transfer event with address(0) as the value of the to parameter.

But that event is essentially symbolic, and by no means does it imply that the tokens are transferred to address(0).

In short:

  • When you burn tokens, the value of totalSupply is decreased
  • When you transfer tokens to address(0), the value of balanceOf[address(0)] is increased
  • Thanks for your comments. The code is from IDEX contract that i am trying to understand. So for the function deposit in the contract. There is no way to get retrieve the balance. There is another deposit function : function depositToken(address token, uint256 amount) { tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); lastActiveTransaction[msg.sender] = block.number; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } What this function do ? What are differences ?
    – chen Crush
    Jun 17, 2020 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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