[Ethereum] Warning! Error encountered during contract execution [execution reverted]

crowdsaleicosoliditysolidity-0.5.xtokens

I have an ERC20 Mintable+Burnable Token created on solidity 6.11 and a sale contract on solidity 5.0
I am getting error when i send ETH to the sale contract.

https://rinkeby.etherscan.io/tx/0xb793a7b7f3d5667a2ad5c38ecae273bd4c2fb7d627aa0383da7ab25a2ee71510

I have given minter role to sale contract.

This is the sale contract code:

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/Crowdsale.sol";

contract BotSale is Crowdsale, MintedCrowdsale, CappedCrowdsale {
constructor (
uint256 rate,
address payable wallet,
IERC20 token,
uint256 cap
)
MintedCrowdsale()
Crowdsale(rate, wallet, token)
CappedCrowdsale(cap)
public
{
// solhint-disable-previous-line no-empty-blocks
    }
}

I have set Rate: 1000000000000000000
and Cap to: 9600000000000000000000000

Just incase if that helps. Though i want to ask, this cap is of tokens or ETH? and should i add decimals to cap?
Also i have read on openzeppelin docs to set rate as 1 if i want to give 1 token in exchange of 1 ETH. So should i add decimals in rate or not?

Best Answer

If you want to issue someone “1 TKNfor every 1 ETH”, and your decimals are 18, your rate is 1 .

To calculate rate please see the OpenZeppelin Contracts documentation: https://docs.openzeppelin.com/contracts/2.x/crowdsales#crowdsale-rate


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

Disclosure: I am the Community Manager at OpenZeppelin

Related Topic