LoginSignup
1
3

More than 5 years have passed since last update.

zeppelin-solidityのcrowdsale

Last updated at Posted at 2018-03-12

crowdsaleを試してみる

zeppelin-solidityにcrowdsaleというのがある。
ICOで使われるものだけど、これを使えばほんの10数行のSolidityコードだけで何とかなるというもの。

minaToken.sol
pragma solidity ^0.4.18;

import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
import "zeppelin-solidity/contracts/token/ERC20/BurnableToken.sol";

contract minaToken is MintableToken , BurnableToken{
    string public constant name = "minaToken";
    string public constant symbol = "MNTK";
    uint8 public constant decimals = 18;
}
minaCrowdsale.sol
pragma solidity ^0.4.18;

import "zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol";
import "zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol";
import "./minaToken.sol";

contract minaCrowdsale is CappedCrowdsale, RefundableCrowdsale {
    function minaCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet) public
    CappedCrowdsale(_cap)
    FinalizableCrowdsale()
    RefundableCrowdsale(_goal)
    Crowdsale(_startTime, _endTime, _rate, _wallet)
    {
        require(_goal <= _cap);
    }
    function createTokenContract() internal returns (MintableToken) {
        return new minaToken();
    }
}
2_deploy_crowdsale.js
var Crowdsale = artifacts.require("./minaCrowdsale.sol");

module.exports = function(deployer, network, accounts) {

    const startTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 86400;
    const endTime = startTime + 1814400;
    const rate = new web3.BigNumber(10);
    const goal = web3.toWei(100, 'ether');
    const cap = web3.toWei(1000 , 'ether');
    const wallet = accounts[0];

    deployer.deploy(Crowdsale, startTime, endTime, rate, goal, cap, wallet);
};

だいたいこれだけで基本的なcrowdsaleが行える。ここのコードの内容は、ほぼzeppelin-solidityのexsampleを使ったです。
ライブラリの方にはmigrateファイルがないのでこれ自体は他の方のBlogを参考にしたです。今この記事を書いてる時点でどこの方のを参考にしたのかがちょっと覚えてないで・・・すみません、割愛させてください。

何が問題かというと・・・

これで十分にデプロイできるのですが、ちょっと問題がありまして・・・。
Gas消費が570万程かかるので、Ropstenにデプロイ出来ない、ということなんですよね。

RopstenのGasLimitが470万程。大幅に足りないのと、Zeppelin-solidityのライブラリをそのまま使っているので、削るのも削れない。
ただ、SlackコミュニティのHi-Etherのところで質問させて頂いた所、GasLimitが470万でうまくいけてる方もいらっしゃるようでして。

調べたり試さなきゃいけないことも、また出てくるという話。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3