0

In ERC20 EOS crowdsale contract, what these three lines(469-471) does?

    function initialize(DSToken eos) auth {        
    assert(address(EOS) == address(0)); //[Someone explained this line here][2]
    assert(eos.owner() == address(this));
    assert(eos.authority() == DSAuthority(0));
  1. When I compile and push the contract on Remix, it works fine. But, no token minted. On debugging, I figured that the initialize() must be called to mint tokens. But, when I execute initialize() with the same contract address as parameter as the crowdsale contract it shows 'Error: Invalid upcode" on second line(line 470). What am I doing wrong here?

  2. I also noticed there is no method called owner() and authority() inside DSToken contract which is passed as argument to EOSSale contract. Then how the contract compiles and run without any error until initialize.

0

The owner/authority methods come from DSAuth. The inheritance tree in this case is DSToken -> DSStop -> DSAuth. Your issues is that eos.owner() is not equal to the address of the crowdsale contract. For this to work, you'll have to call setOwner(crowdsaleAddress) and setAuthority(0x0) on the token contract.

  • I did what you are suggesting. But, still getting the same "Invalid opcode" error at line 470. Rre you talking about two contracts here(one is EOS and another is EOSsale)? I have only one contract(EOSSale.sol), I deployed that from address 0x99c4....13c and I call setOwner(0x99c4....13c). So, basically the deployment address and Crowdsale address are same. Anything else should I check? @flygoing – LexyGreen Mar 15 at 10:28
  • Are you passing the crowdsale address or the token address to initialize? – flygoing Mar 15 at 12:52
  • Crowdsale address. Aren't they both same. Crowdsale address is my wallet address from which I deployed my contract. Which one is Token address? – LexyGreen Mar 15 at 13:16
  • I am deploying the contract EOSSale.sol from address : 0xca35b7d915458ef540ade6068dfe2f44e8fa733c , then call the setOwner(0xca35b7d915458ef540ade6068dfe2f44e8fa733c) as you suggested, then setAuthority(0x0000000000000000000000000000000000000000) and finally calling the Initialize(0xca35b7d915458ef540ade6068dfe2f44e8fa733c) method. Is it correct? – LexyGreen Mar 15 at 13:27
  • The crowdsale and the token are two separate contracts. You need to create the token contract, and then the crowdsale contract, then set the owner of the token contract to the crowdsale contract, and set the authority of the token contract to 0x0. – flygoing Mar 15 at 14:50

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.