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
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
})
});
}