好的,所以我发现Openzeppelin是一种稍微容易使用的代码,它比Solidity解释得更好。但现在我的问题是数学题。我也不是数学家,我也无法理解它是如何工作的。因此,如果我想要一个例子中的每一个符号有3个以太,18小数,另一个则是8个小数,我如何将它输入到代码中,因为我现在所拥有的是不被接受的,我会得到数学位和构造函数部分的错误。请有人向我解释这一点,突出显示正确的库需要什么或输入,这样我就不会有任何错误。
我正在使用Metamsk Web.3,Remix,Solidity和Openzeppelin。
谢谢你们的帮助,我真的很感激你们的帮助。
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/CappedCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/CappedCrowdsale.sol";
/**
* @title SimpleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
*
contract SimpleCrowdsale is Crowdsale {
constructor (
uint256 rate, 10**18
address payable wallet,
IERC20 token
)
public
Crowdsale(rate, wallet, token)
{
}
contract MyCrowdsale is Crowdsale, CappedCrowdsale, TimedCrowdsale {
constructor(
uint256 rate, 10**18 // rate, in bits
address payable wallet, // wallet to send Ether
IERC20 token, // the token
uint256 cap, 66028410000000000000000000 // total cap, in wei
uint256 openingTime, Date(2020, 4, 02, 16, 30) // opening time in unix epoch seconds
uint256 closingTime Date(2020, 4, 17, 16, 30) // closing time in unix epoch seconds
)
CappedCrowdsale(cap)
TimedCrowdsale(openingTime, closingTime)
Crowdsale(rate, wallet, token)
public
{
// nice, we just created a crowdsale that's only open
// for a certain amount of time
// and stops accepting contributions once it reaches `cap`
}
}
contract MyCrowdsale is Crowdsale, TimedCrowdsale, PostDeliveryCrowdsale {
constructor(
uint256 rate, 10**18 // rate, in bits
address payable wallet, // wallet to send Ether
IERC20 token, // the token
uint256 openingTime, Date(2020, 4, 02, 16, 30) // opening time in unix epoch seconds
uint256 closingTime Date(2020, 4, 17, 16, 30) // closing time in unix epoch seconds
)
PostDeliveryCrowdsale()
TimedCrowdsale(openingTime, closingTime)
Crowdsale(rate, wallet, token)
public
{
// nice! this Crowdsale will keep all of the tokens until the end of the crowdsale
// and then users can `withdrawTokens()` to get the tokens they're owed
}
}发布于 2020-04-06 07:08:50
查看有关Crowdsale的文档,其中包括如何计算费率:https://docs.openzeppelin.com/contracts/2.x/crowdsales#crowdsale-rate
如果你对使用OpenZeppelin有疑问,你也可以在社区论坛上问:https://forum.openzeppelin.com/
披露:我是OpenZeppelin的社区经理
https://ethereum.stackexchange.com/questions/82132
复制相似问题