Link of the contract:https://github.com/laronlineworld/autoswap/blob/main/autoswap.sol
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT
contract BIMPCrowdsale is Crowdsale , CappedCrowdsale{
address public owner;
uint256 public investorHardCap =250000000000000000;
mapping(address => uint256) private _contributions;
constructor (uint256 rate,uint256 cap, address payable wallet, IERC20 token)
public
Crowdsale(rate, wallet, token)
CappedCrowdsale(cap)
{
owner = msg.sender;
// solhint-disable-previous-line no-empty-blocks
}
modifier onlyOwner() {
if (owner == msg.sender) _;
}
function _preValidatePurchase(
address beneficiary,
uint256 weiAmount
)
internal view
{
super._preValidatePurchase(beneficiary, weiAmount);
require( _contributions[beneficiary].add(weiAmount) <= investorHardCap, "Beneficiary's cap exceeded");
}
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
super._updatePurchasingState(beneficiary, weiAmount);
_contributions[beneficiary] = _contributions[beneficiary].add(weiAmount);
}
using SafeERC20 for IERC20;
function transferToken(IERC20 token, address to, uint256 amount) public onlyOwner {
token.safeTransfer(to, amount);
}
//new function
function setInvestorHardCap (uint256 newInvestorHardCap) public onlyOwner() {
investorHardCap = newInvestorHardCap;
}
// function InvestorHardCap() public view returns (uint256) {
// return investorHardCap;
// }
function setRate(uint256 newRate) public onlyOwner() {
rate = newRate;
}
function setCap(uint256 newCap) public onlyOwner() {
cap = newCap;
}
function setWallet(uint256 newWallet) public onlyOwner() {
wallet = newWallet;
}
function setTokenAddress(uint256 newTokenAddress) public onlyOwner() {
token = newTokenAddress;
}
}