0
pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/Crowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/distribution/FinalizableCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/emission/AllowanceCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/validation/PausableCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/dfbdb11605bab94df6a6b864afc1a068e94a67cc/contracts/token/ERC20/IERC20.sol";

/**
 * @title SampleCrowdsale
 * @dev This is an example of a fully fledged crowdsale.
 * The way to add new features to a base crowdsale is by multiple inheritance.
 * In this example we are providing following extensions:
 * CappedCrowdsale - sets a max boundary for raised funds
 * RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
 * MintedCrowdsale - assumes the token can be minted by the crowdsale, which does so
 * when receiving purchases.
 *
 * After adding multiple features it's good practice to run integration tests
 * to ensure that subcontracts works together as intended.
 */
contract CresstCrowdsale is CappedCrowdsale,TimedCrowdsale,Pausable,IncreasingPriceCrowdsale,AllowanceCrowdsale,FinalizableCrowdsale {
    uint constant TOKEN_DECIMALS = 18;
    uint8 constant TOKEN_DECIMALS_UINT8 = 18;
    uint constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS;
    
    constructor (
        uint256 openingTime,   // opening time in unix epoch seconds
        uint256 closingTime,        // closing time in unix epoch seconds
        uint256 rate,               // rate, in TKNbits
        address payable wallet,     //the wallet address that will receive the donation
        address payable tokenWallet,  // the crowd sale wallet address
        uint256 initialRate,            //the rate it will start to increase its always greater
        uint256 finalRate,              //the rate it will end when crowd sale stops always  smaller
        uint256 cap,            // total amount for the Crowdsale, in wei
        IERC20 token            // the token contract address
    ) 
    Crowdsale(rate,wallet,token) 
    CappedCrowdsale(cap)
    TimedCrowdsale(openingTime, closingTime)
    IncreasingPriceCrowdsale(initialRate,finalRate)
    AllowanceCrowdsale(tokenWallet)
    FinalizableCrowdsale()
    
    public {
        
        
    }
    
    
    /**
     * @dev Admin can move end time.
     * @param _endTime New end time.
     */
     function setEndTime(uint _endTime) public onlyOwner notFinalized {
        require(_endTime > openingTime);
        closingTime = uint32(_endTime);
    }


     function setStartTime(uint _startTime) public onlyOwner notFinalized {
        require(_startTime < closingTime);
        openingTime = uint32(_startTime);
    }

    function setHardCap(uint _hardCapTokens) public onlyOwner notFinalized {
        require(_hardCapTokens * TOKEN_DECIMAL_MULTIPLIER > cap);
        cap = _hardCapTokens * TOKEN_DECIMAL_MULTIPLIER;
    }
    
     function setNewRate(uint _NewRate) public onlyOwner notFinalized {
        rate = _NewRate;
    }
    
       
}

Here I am trying to add functions that can be used to modify the startdate, enddate, cap and rate but its giving me serious error. If I remove the four functions, the code will be fine but I need those four functions (setEndTime, setStartTime, setHardCap, setNewRate). Please, what should I do?

1 Answer 1

0

In order to use onlyOwner modifier the contract should inherit from Ownable.

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/ownership/Ownable.sol";

contract CresstCrowdsale is ..., Ownable {

    function setEndTime(uint _endTime) public onlyOwner notFinalized {
        require(_endTime > openingTime);
        closingTime = uint32(_endTime);
    }
}

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.