Ethereum Crowdsale Discussion


What do you mean by accessing the functions? Do you mean executing the functions or changing the contract?


Got it!

Thanks a lot Filip! Appreciate the help :slight_smile:


In token.sol at line 93: newOwner = address(0);

I do not understand the (0) ?

also, at line 204, what does allowed[msg.sender][spender] = tokens; means ?
I still do not understand a “double mapping” ==> mapping(address => mapping(address => uint)) allowed; (line 109)

thank you,



address(0) is just the zero address. Meaning the address containing only zeros like this: 0x00000000…00. If you are familiar with hexidecimal you know that 0 = 0x00000000…00. So it’s just an address like any other. However, the way it is used can have special meaning. In the token contract, the zero address is used to “burn” tokens. So all tokens that are sent to the zero address would be consider “burnt” and no longer in existance. You will find more about this if you google for “solidity address 0”.

allowed[msg.sender][spender] is a 2 dimensional array. You can find more information about that generally here: There are plenty of good explanations for 2d arrays in blog posts and youtube videos.

The double mapping is really nothing special. Normally you have a mapping that takes a key and points to a value. In a double mapping that value is not an integer or a string, instead it’s another mapping, that takes a new key and points to another value. In your example that value is an integer. If you still haven’t grasped the concept, I would advice you to draw. Start by drawing how a normal mapping works, for example addresses pointing to integers.

After that you can attempt to draw the double mapping, where each address points to individual mappings instead.


I mean executing the functions.


As long as the contract is deployed to a blockchain and not only the VM you can access it from for example myetherwallet. All you need is the address and the ABI string. You can get those from within remix for example.


In the video he transfers 10 thousand tokens. To actually transfer 10 thousand tokens you need to type in this number “10000000000000000000000” since there are 18 decimals.


If you type in “10000” then you will get the following…


Question: what happens if the fundingGoalReached not reached function is triggered and the funds are transferred back to the sender and after a few transfers you run out of gas. What happens in that case?


Is there a way one can check if a wallet is able to receive ERC20 tokens? Often it happens, that people send ETH from their (for example) Binance account which should be rejected by the contract to avoid unnecessary support issues.


Hi Filip,

In the token.sol contract, in the constructor, the Transfer event has three arguments, address(0), our MEW address, and _totalSupply). What is address(0), is that a specific address? I think it appearing elsewhere within the contract. For example the function for total supply returns _totalSupply - balances[address(0)].

Update: I found the answer, so it’s ok! For anyone interested, here’s the link which I got the information from:


Hi Hiro and Filip,

I was looking through Crowdsale Part 2, and in the video when Filip was writing the code for safeWithrdrawal(), I noticed that we were supposed to type msg.sender.send(amount) (timestamp in the video is 17:45).

Subsequently, we needed to check if the transfer failed or not, using an if statement. However, after writing that in, we did not include the actual sending of the funds. We only input code for “if it fails”, but if the transfer is successful, I don’t see any code for such an action. Could that be where the problem lies?

On that note, I am a bit with that portion. for the lines

            balanceOf[msg.sender] = amount;
if(fundingGoalReached && msg.sender == beneficiary){
        fundingGoalReached = false;

Can transfers be executed within the if statement? Because within this function, msg.sender.send(amount) and beneficiary.send(totalAmountRaised) only appear in the if statement condition, and no where else in the function. Does that mean that they were executed, and then assessed as true or false, all within the if statement itself?


Good question. The funds are not transferred back automatically if the crowdsale fails. Every contributor needs to call the safeWithdrawal function themselves to withdraw their own funds. So we don’t have that issue with gas running out.


No, not through programming in the contract. The best solution atm is to simply ask the user what wallet they are using and only accepting eth if the user has a EIP-20 wallet.

I believe the ERC223 token standard solves a big part of these issues since it doesn’t allow transfers to contracts that doesn’t support the token.


Well, in the beginning of that function we set the balance of the msg.sender to 0. So if the transfer succeeds we don’t need to do anything else. If it fails however, we need to reset the balance to what it previously was. Since no successfull transfer actually took place. I hope I answered your question. Take a look at the entire function once again and let me know if you need more help.


Dear Filip,

I have some questions and issues I can’t seem to understand/solve:

  1. as apeondrums asked, in the safeWithdrawal function there is no “send” command, only the checking, wether the amount went through correctly. But, since there is no sending command, how does it check, wether it went through?

  2. what is the unit of the msg.value? Is it ETH, WEI, or FilipCoin?

  3. How is the fundingGoalReached will be set to true? This is only set by the function checkGoalReached, but what fires off this function? nothing calls it.

  4. Do I understand correctly, that the constructor function Crowdsale gets fired immediately at the deployment, therefore When we are setting the crowdSaleDeadline = now + …; the “now” value will be equal to the timestamp of the deploy?

  5. I tried to send tokens to the crowdsale address, however, the transaction reverted:
    Just for clarification, is my following understanding correct?:
    I have created a new (second) account on MEW and sent some ETH from my (first) MetaMask account to it. Also, In the FilipCoin contract it is defined, that this second MEW adress has the totalsupply of the FilipCoin. But, I can interact with these tokens on my account only through the contract and that is why I have to send the tokens to the crowdsale contract through the Interaction with the Contract.

So I go to the contracts on myetherwallet and paste in the filipcoin contract’s address. Then go to the compile tab in Remix and copy the details of the filipcoin contract to the ABI interface. Select transfer and paste in the crowdsale’s address. I put in how much token I want to transfer (I have tried with both 10000 and 10e22 amount). It sends the transaction, but it doesn’t go through. Where could be the problem? I have defined the same parameters as you have with (my own Metamask Address,10,100,1,FilipCoin contract Address).


And a general comment, for a little more clarification:
It would be great, if the different types and variables would have unique naming. E.g. don’t name the contract, the token, the symbol and it’s name all FilipCoin, so it is always clear, which one is used


Good questions.

  1. Yes there is. On line 87. Here is where we first send the amount though the send() function. Then we check the result in the if statement, all in the same line.

  2. Wei

  3. Anyone can call that function after the deadline has ended. You, me, the owner of the crowdsale, any investor can call it. It’s not done automatically though.

  4. Yes, correct. The now variable is defined in the solidity language as the current timestamp.

  5. Yes that’s corrent. I’m not sure why your transaction failed. It’s very difficult to know what’s going on, something is probably wrong in your contract or in how you interact with it. But I’m not sure.It could depend on a lot. Is it still not working for you?

In the airdrop video, we look at an alternative way to handle to tokens back and forth. You will probably get a better understanding after that.


Hello Flip,
I am really enjoying the course - thank you and to Ivan.

I am confused by the following line in the constructor.
Transfer(address(0), 0x49894CA8df470d5e0448A602373EdE1780AA4450, _totalSupply);

I cannot see what this does. I have read up on the special case 0x address. To me teh above line looks like transferring the entire balance to the 0 or spent pool ?

Many thanks


Hi Paul,

That’s a good question. I was kind of confused by that too when I looked at it. I should have covered it in the video maybe… Either way, that line calls the Transfer event, not the Transfer function. You know that by looking at the arguments, it has 3 arguments while the Transfer function only has 2.

What that does is that it makes it clear from the start which address holds all the tokens by emitting an event. The event says that the entire balance has been transferred FROM address zero to 0x49894CA8df470d5e0448A602373EdE1780AA4450.

Was my explanation clear enough?


Hi Filip,
Many thanks - i see this distinction now. It is not a transfer but a notification of creation/initial transfer event.
many thanks,