REVERT Error when buying token from crowdsale

hello everyone.
so i am trying my hands on creating a token and a crowdsale (default) with openzeppelin v2.5.1.
i transferred the crowdsale token from the owner into the crowdsale token successfully.
i get the below error any time i try to buy tokens.
Error: Returned error: VM Exception while processing transaction: revert SafeERC20: low-level call failed

i tried researching around but most of the solutions around was because the crowdsale didnt have enough tokens but in this case, it is not so. unless i am not seeing something right.
kindly assist.

pragma solidity ^0.5.16;
import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;
import “@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol”;
import “@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol”;

contract MulToken is ERC20, ERC20Detailed{
    ERC20Detailed("Mul Token", "MUL", 18) public{
        _mint(msg.sender, 100000000); //mint total number of token TO ADMIN

pragma solidity ^0.5.16;

import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract MulTokenCrowdSale is Crowdsale{

    constructor(uint256 _rate,address payable _wallet, IERC20 _token)
    Crowdsale(_rate,_wallet,_token) public{      


const {BN,ether } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const MulToken = artifacts.require('MulToken');
const MulTokenCrowdSale = artifacts.require('MulTokenCrowdSale');

  contract('MulTokenCrowdSale', function(accounts){
    beforeEach(async function(){
       this.rate = new BN(110);
       this.value = 420000000000000000;
      //  this.expectedTokenAmount = rate.mul(value);
      //  this.tokenAllowance = new BN('10').pow(new BN('22'));
       this.tokenWallet = accounts[1];
       this.wallet = accounts[2];
       this.buyer = accounts[3];

        this.token = await{ from: accounts[0] });
        this.crowdsale = await
        await this.token.transfer(this.crowdsale.address, 20000000);
    describe('accepting payments', function () {
     it('should create crowdsale with correct parameters', async function () {
        expect(new BN(await this.crowdsale.rate()));
        expect(await this.crowdsale.wallet());
        expect(await this.crowdsale.token());
      it('should accept payments', async function () {
        const investmentAmount = ether('1');
        const expectedTokenAmount = this.rate.mul(investmentAmount);
        await this.crowdsale.buyTokens(accounts[8], { value: investmentAmount, from: accounts[8] });
        expect(await this.token.balanceOf(accounts[8]));


try on testnet too, on VM I can’t fix this. Btw remember to set gas limit to 2999999

1 Like

alright i will plug to infura and give feedback

i am trying to migrate to ropsten and i am geting this error

Migrations" – insufficient funds for gas * price + value.

here is my provide config
ropsten: {
provider: () => new HDWalletProvider(mnemonic,${infuraKey}),
network_id: 3, // Ropsten’s id
gas: 5500000, // Ropsten has a lower block limit than mainnet
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )