1

Ok so Ive found Openzeppelin a slightly easier Code to use, it explains better than Solidity does. But now my problem is the Math bit. Im no mathematician neither and cannot get my head around how it works. So if I want 3 ether per token at 18 decimals for the one example, and 8 decimals for the other for example, how do I input it into the code because what I have now is not accepted, I get errors with the math bit as well as the part for constructor. Please can somebody explain this to me and highlight whats the correct library needed or input so that I dont get any errors.

Im using Metamsk Web.3, Remix, Solidity and Openzeppelin.

Thanks a mill guys, I really would appreciated the help.

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
    }
}

1 Answer 1

0

Have a look at the documentation on Crowdsale Rate which covers how to calculate the rate: https://docs.openzeppelin.com/contracts/2.x/crowdsales#crowdsale-rate

If you have questions on using OpenZeppelin you can also ask in the Community Forum: https://forum.openzeppelin.com/

Disclosure: I am the Community Manager at OpenZeppelin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.