1

In various tutorials and previous releases of zeppelin, variables like _rate were explicit in the code. Now, however, these are left in a function (SampleCrowdsale), and I'm not sure what I'm supposed to do with that.

https://github.com/OpenZeppelin/zeppelin-solidity/blob/bd84db735deb958064dd954c2994b0b44f142812/contracts/examples/SampleCrowdsale.sol

All the tutorials simply have you define all the variables, then create the coin. In this new version, are we somehow calling the function "SampleCrowdsale()" outside of the contract itself? If so, how would one go about doing that. Or are we plugging in the variable values right here?

I'm sure there's some basic overarching idea that I'm missing here, so apart from specifics on how to get this to work, it would be great to understand the overall idea.

Thanks in advance.

  • My guess is they are in the imported files ( first couple of lines of code) – Samuel Dare Oct 3 '17 at 22:06
  • Thanks @Data_Kid but definitely not the case. You can search the codebase for it, and it's not in any of the imports. There is a sample javascript initiation of it, which is why I assume there's some kind of external initiation that must occur, but finding it hard to Google/understand that. – daprezjer Oct 3 '17 at 22:22
2

SampleCrowdsale is the contract constructor. It is called automatically when the contract is created. You can tell it is the constructor because the name of the method is the same as the name of the contract.

You can pass these variables when creating the contract or you could deploy it from within another contract and pass those variables in.

You could also superclass SampleCrowdsale and set these variables in the inheritance like:

contract SuperSampleCrowdsale is SampleCrowdsale(160000000, 170000000, 100, 5000, 500000, 0x0) {...}
  • Thanks Alec, what I was missing was the "You can pass these variables when creating the contract" part. Now I see when I run this in Remix, it asks me for these variables when I attempt to create the contract. That's what I was missing. Rerunning through the tut here also made me come to this realization: ethereum.org/token – daprezjer Oct 3 '17 at 22:46

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.