I'm trying to use the buyTokens function of the Zepellin Crowsale interface, but this gives me an error, without any log to be able to debug

contract TokenA is MintableToken, PausableToken, DetailedERC20 {
    constructor(string _name, string _symbol, uint8 _decimals)
        DetailedERC20(_name, _symbol, _decimals)


contract TokenACrowdsale is Crowdsale, MintedCrowdsale {

    uint256 _rate, 
    address _wallet,
    ERC20 _token 
    Crowdsale(_rate, _wallet, _token)


truffle console


account[0]=8eth account1=4eth

let token=await TokenA.new('va','va',18)

token.balanceOf(accounts[0])  //0

await token.mint(accounts[0],web3.utils.toWei(10000000),token.address)
token.balanceOf(accounts[0]) //10000000 va

let crow=await TokenACrowdsale.new(web3.utils.toWei('500'),accounts[0],token.address)

await token.transfer(crow.address,web3.utils.toWei('200000','ether'))

token.balanceOf(crow.address) // 2000000 va

await crow.buyTokens(accounts[1],{from:accounts[1],value:web3.utils.toWei('1','ether')}) //Error

ropsten transaction

how do i fix this

enter image description here


You are using MintedCrowdsale which requires for the crowdsale to have mint permissions on the token contract.

await token.addMinter(crow.address)

If you do not want for the crowdsale to mint tokens you have to inherit from AllowanceCrowdsale.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.