首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署Crowdsale.sol -错误

部署Crowdsale.sol -错误
EN

Ethereum用户
提问于 2020-12-04 08:20:26
回答 1查看 166关注 0票数 0

为了能够购买MyToken,我在哪里包括费率(令牌/ETH),如下面的代码从大众销售的Openzeppelin文档到我的deploy_contract.js或MyToken.sol?以及如何插入它?

代码语言:javascript
复制
new Crowdsale(
    1,             // rate in TKNbits
    WALLET,     // address where Ether is sent
    TOKEN  // the token contract address
);

下面是来自Openzeppelin的Simpletoken、Crowdsale和部署合同:

代码语言:javascript
复制
/ contracts/SimpleToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.5;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

contract SimpleToken is Context, ERC20, ERC20Detailed {
    constructor(
        string memory name,
        string memory symbol,
        uint256 initialSupply
    ) public ERC20Detailed(name, symbol, 18) {
        _mint(_msgSender(), initialSupply);
    }
}

// contracts/SimpleCrowdsale.sol
// SPDX-License-Identifier: MIT
    pragma solidity ^0.5.5;
    
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";

contract SimpleCrowdsale is Crowdsale {
    constructor(
        uint256 rate,
        address payable wallet,
        IERC20 token
    ) public Crowdsale(rate, wallet, token) {}
}

// migrations/2_deploy.js
// SPDX-License-Identifier: MIT
const SimpleToken = artifacts.require("SimpleToken");
const SimpleCrowdsale = artifacts.require("SimpleCrowdsale");

module.exports = async function (deployer, network, accounts) {
  await deployer.deploy(SimpleToken, 'Simple Token', 'SIM', '10000000000000000000000');
  const token = await SimpleToken.deployed();
  
  await deployer.deploy(SimpleCrowdsale, 1, accounts[0], token.address);
  const crowdsale = await SimpleCrowdsale.deployed();

  token.transfer(crowdsale.address, await token.totalSupply())
};
EN

回答 1

Ethereum用户

回答已采纳

发布于 2020-12-05 10:13:10

您应该将其包含在deploy_contract.js中,因为您已经在这里这样做了:

代码语言:javascript
复制
await deployer.deploy(SimpleCrowdsale, 1, accounts[0], token.address);

论点1是您所提供的速率。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/90774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档