Returned error: VM Exception while processing transaction: revert

Hey there,

I am getting an error "Returned error: VM Exception while processing transaction: revert" when trying to send a transaction to a Crowdsale contract. This contract does not have any tokens but does inherit MintedCrowdsale and does have Minter role to the token contract (which is ERC20Mintable) so I believe I do not need to transfer tokens to it on deployment?

I am wondering if it may be something to do with the crowdsale contract code? It is both capped and mintable, is this an issue? Also the decimals for the token must be set to zero

Thank you

:1234: Code to reproduce

Crowdsale contract code

pragma solidity ^0.5.8;

// Imports
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/validation/CappedCrowdsale.sol";

contract CONORCrowdsale is MintedCrowdsale, Ownable, CappedCrowdsale {
  constructor(
    ERC20Mintable _token,
    uint256 _rate,
    address payable _wallet,
    uint256 _cap
  )
    public
    Crowdsale(_rate, _wallet, _token)
    CappedCrowdsale(_cap)
  {
    
  }
}

Token contract

pragma solidity ^0.5.8;

// Imports
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";

// Main token smart contract
contract CONORToken is ERC20Mintable {
  string public constant name = "Conor";
  string public constant symbol = "CONOR";
  uint8 public constant decimals = 0;
}

Deployment config

const token = artifacts.require('../contracts/CONORToken.sol')
const crowdsale = artifacts.require('../contracts/CONORCrowdsale.sol')

module.exports = async function (deployer, network, accounts) {
    return deployer
        .then(() => {
            return deployer.deploy(token, {
                gas: 5500000,
                gasPrice: gasPrice,
                from: account
            })
        })
        .then(async () => {
            let latestBlock = await web3.eth.getBlock('latest');
            let gasLimit = latestBlock.gasLimit;
            return deployer.deploy(
                crowdsale,
                token.address,
                rate,
                wallet,
                cap, {
                    gas: 5500000,
                    gasPrice: gasPrice,
                    from: account
                },
            )
        })
        .then(async () => {
            var tokenContract = new web3.eth.Contract(token.abi, token.address)
            await tokenContract.methods.addMinter(crowdsale.address).send({
                from: account
            })
        });
}

:computer: Environment

We no longer offer the Crowdsale contracts so support is limited.

What value are you using for rate? 0 decimals may be related to the cause of the issue.

For rate I am using:

 const rate = new web3.utils.BN('10000000')

could it be that the crowdsale contract is both Mintable and Capped?

I don't think the combination of Mintable and Capped is causing an issue but you can always try removing one and seeing if it works. You should also try using rate = 1. But I don't know what else to suggest, sorry.

1 Like