It's no secret - ICOs are all the rage these days. Many new companies are raising millions of dollars by selling their tokens in crowdsale. If you are reading this article, you are probably pursuing the idea of doing an ICO. I wrote an article a few ...
hashnode.comI tried this on ropsten testnet. Everything worked fine.... Then i deployed on mainnet , the tokens generated were invalid. the smart contract is invalid, lost etherum used in creating on mainnet.
Try to deploy your crowdsale smart contract on the Ethereum blockchain through mywish.io
if ((stage == CrowdsaleStage.PreICO) && (token.totalSupply() + tokensThatWillBeMintedAfterPurchase > totalTokensForSaleDuringPreICO)) {
msg.sender.transfer(msg.value); // Refund them
EthRefunded("PreICO Limit Hit");
return;
}
It is better to user revert here?
would you share your version truffle, zeppelin ?? or anybody here can help me ?
$ truffle compile
Compiling .\contracts\ElectroLightCrowdsale.sol...
Compiling .\contracts\ElectroLightToken.sol...
Compiling .\contracts\Migrations.sol...
Compiling zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol...
Compiling zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol...
Compiling zeppelin-solidity/contracts/token/MintableToken.sol...
Compiling zeppelin-solidity\contracts\crowdsale\Crowdsale.sol...
Compiling zeppelin-solidity\contracts\crowdsale\FinalizableCrowdsale.sol...
Compiling zeppelin-solidity\contracts\crowdsale\RefundVault.sol...
Compiling zeppelin-solidity\contracts\math\SafeMath.sol...
Compiling zeppelin-solidity\contracts\ownership\Ownable.sol...
Compiling zeppelin-solidity\contracts\token\BasicToken.sol...
Compiling zeppelin-solidity\contracts\token\ERC20.sol...
Compiling zeppelin-solidity\contracts\token\ERC20Basic.sol...
Compiling zeppelin-solidity\contracts\token\MintableToken.sol...
Compiling zeppelin-solidity\contracts\token\StandardToken.sol...
zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol:22:37: ParserError: Expected token LBrace got 'View'
function validPurchase() internal view returns (bool) {
^
,zeppelin-solidity/contracts/crowdsale/Crowdsale.sol:94:37: ParserError: Expected token LBrace got 'View'
function validPurchase() internal view returns (bool) {
^
,zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol:56:33: ParserError: Expected token LBrace got 'View'
function goalReached() public view returns (bool) {
^
,zeppelin-solidity/contracts/math/SafeMath.sol:9:47: ParserError: Expected token LBrace got reserved keyword 'Pure'
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
^
,zeppelin-solidity/contracts/token/BasicToken.sol:38:45: ParserError: Expected token LBrace got 'View'
function balanceOf(address _owner) public view returns (uint256 balance) {
^
,zeppelin-solidity/contracts/token/ERC20.sol:12:61: ParserError: Expected token LBrace got 'View'
function allowance(address owner, address spender) public view returns (uint256);
^
,zeppelin-solidity/contracts/token/ERC20Basic.sol:11:42: ParserError: Expected token LBrace got 'View'
function balanceOf(address who) public view returns (uint256);
^
,zeppelin-solidity/contracts/token/StandardToken.sol:60:63: ParserError: Expected token LBrace got 'View'
function allowance(address _owner, address _spender) public view returns (uint256) {
^
Compiliation failed. See above.
Hello thanks for the good article.
uint256 unsoldTokens = totalTokensForSale - alreadyMinted;
if (unsoldTokens > 0) {
tokensForEcosystem = tokensForEcosystem + unsoldTokens;
}
Just because of these 3 lines I am getting error : could potentially lead to re-entrancy vulnerability. <br/><i>Note:</i> Modifiers are currently not considered by this static analysis.
Hello Sandeep Panda, first of all, thanks for writing this awesome article. This really helps. I followed everything and it worked all fine until when I added the token in meta mask it is showing me 0 nT (nT is the symbol I updated).
What might I be doing wrong?
Hi Sandeep, Great work! Based on your work I have used geth to inspect what happens inside the ethereum network when executing the testing items. Here I documented the whole process and hope to serve as a companion guide to your great work. You can find it here . cheers, kc
I would like to add the following token distribution mechanism: to let each user get extra tokens proportional to the total number of tokens sold, i.e. the more tokens are sold in total, the more extra tokens each user will receive. How to do this in the codes? Thanks.
Sandeep - any chance you'd be willing to write a similar article or ebook on how to do these exact things using Stellar Smart Contracts?
Hi gys After I Deploy to Ropsten TestNet Success, then I go to MetaMask -> Tokens -> Add Token. Paste the token address, but 0 in my Token :( This TX ropsten.etherscan.io/tx/0xa85ba8a43a7cb7a95fe0fde…
Please have a look on this issue : ethereum.stackexchange.com/questions/42122/declar…
Getting error : browser/mycontract.sol:64:27: DeclarationError: Identifier not found or not unique. contract StandardToken is ERC20, BasicToken { ^---^
browser/mycontract.sol:64:34: DeclarationError: Identifier not found or not unique. contract StandardToken is ERC20, BasicToken { ^---^
Hello,
An error occurred while testing
Contract: HashnodeCrowdsale ✓ should deploy the token and store the address (97ms) ✓ should set stage to PreICO (109ms) 1) one ETH should buy 5 Hashnode Tokens in PreICO
Events emitted during test:
---------------------------
Mint(to: <indexed>, amount: 5000000000000000000)
Transfer(from: <indexed>, to: <indexed>, value: 5000000000000000000)
TokenPurchase(purchaser: <indexed>, beneficiary: <indexed>, value: 1000000000000000000, amount: 5000000000000000000)
EthTransferred(text: forwarding funds to wallet)
---------------------------
✓ should transfer the ETH to wallet immediately in Pre ICO (572ms)
✓ should set variable `totalWeiRaisedDuringPreICO` correctly (41ms)
✓ should set stage to ICO (103ms)
2) one ETH should buy 2 Hashnode Tokens in ICO
Events emitted during test:
---------------------------
Mint(to: <indexed>, amount: 3000000000000000000)
Transfer(from: <indexed>, to: <indexed>, value: 3000000000000000000)
TokenPurchase(purchaser: <indexed>, beneficiary: <indexed>, value: 1500000000000000000, amount: 3000000000000000000)
EthTransferred(text: forwarding funds to refundable vault)
---------------------------
✓ should transfer the raised ETH to RefundVault during ICO (265ms)
✓ Vault balance should be added to our wallet once ICO is over (767ms)
7 passing (3s) 2 failing
1) Contract: HashnodeCrowdsale one ETH should buy 5 Hashnode Tokens in PreICO: Uncaught ReferenceError: HashnodeToken is not defined at test/TestCrowdsale.js:26:32 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)
2) Contract: HashnodeCrowdsale one ETH should buy 2 Hashnode Tokens in ICO: Uncaught ReferenceError: HashnodeToken is not defined at test/TestCrowdsale.js:69:32 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)
I would like the tokens to be distributed at the end of the ico, how can we do this?
Hi Sandeep, thanks for your great post.
I am having problems when I try to test on Ropsten. I successfully passed Truffle test; but on
truffle migrate --network ropsten
I got this:
Running migration: 1_initial_migration.js
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
insufficient funds for gas * price + value
I Tried to change gas value many times, but nothing happened.
Could you help me?
thanks
How to manage ICO stage after contract is deployed?
Where can I find examples of using setCrowdsaleStage() and finish() functions?
Now... Once the ico is finished, how can I see the balance of tokens that have been returned to the addresses that have participated?
web3.eth.getBalance(accounts[0]);
Shows me the eth balance, not the token balance.
Thank you Sandeep.
I found a little bit issue where after i bought every token in the PreICO, and start to buy the token in ICO, I couldn't get the token into my account. Does anyone know why
Does anyone else have an issue calling the "finish()" function? When I try to invoke it I get a "gas limit too high" error.. no matter what I try to set it at it won't accept, it fails... have tried using Mist to access the contract after it's deployed to Ropsen
Great write up, works perfectly. Well done! What is involved in getting this to mainnet, just changing the network?
Everything works great, thank you.. my question is once you deploy to Ropsten test network how do you go about interacting with the contract to call finish() ?
What are the ways to interact with the contract once it's on Ropsten?
Thanks.
Also, for anyone else trying out this tutorial but are using the latest version of zeppelin-solidity, I have found the following changes helpful.
(1) In HashnodeToken.sol change the filepath to include the ERC20 folder
import 'zeppelin-solidity/contracts/token/ERC20/MintableToken.sol';
(2) If you are unable to deploy the contract because of a gas issue, try updating the gas amount in truffle.js to reflect the limit in ganache. "gas: 6721974"
Hope this helps someone!
victor perez
productor
hola como construimos la frond end para la ICO