So, I have written a crowdsale and configured it to change rate after every purchase. I just want to confirm that my way on changing rate is correct here.
This is what I am doing.
uint256 public currentRate = 0;
constructor(
uint256 initialRate,
address payable wallet, //This is where ETH/funds go to
IERC20 token,
address tokenWallet //this wallet holds the tokens($BOOKS)//
)
AllowanceCrowdsale(tokenWallet)
Crowdsale(initialRate, wallet, token)
public
{
currentRate = initialRate;
}
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
// over riding the post purchase method to update the rate
uint256 updatedBy = 1000000000000000; // 0.001 ethers in weis
currentRate = currentRate.add(updatedBy);
}