Hi
We have created the crowd sale smart contract .This is my Token smart contract
//SPDX-License-indetifier :Unlicense
pragma solidity ^0.5.0;
import "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "../node_modules/@openzeppelin/contracts/GSN/Context.sol";
contract Token is Context , ERC20, ERC20Detailed {
constructor (string memory _name ,string memory _symbol ,uint8 _decimals,uint256 _initialsupply) public ERC20Detailed(_name ,_symbol, _decimals){
_mint(_msgSender(), _initialsupply * (10 ** uint256(_decimals)));
}
}
and this is my crowd sale contract
contract CrodsaleContract is Crowdsale{
constructor(
uint _rate,
address payable _wallet,
IERC20 token,
)
public
Crowdsale(_rate ,_wallet ,token)
{
}
and this is my migration code
module.exports = async function (deployer ,network, accounts){
console.log(accounts[0])
await deployer.deploy(TOKEN,"US1 Token" ,"US1",18,1000000000);
const token = await TOKEN.deployed();
await deployer.deploy(CrodsaleContract, 1, accounts[0], token.address)
const crowdsale = await Us1Crowdsale.deployed();
token.transfer(crowdsale.address ,await token.totalSupply())
// console.log(crowdsale);
await crowdsale.sendTransaction({value: web3.utils.toWei('10', 'gwei'), gas: '220000'})
// const trans= await crowdsale.buyTokens(accounts[0], { value: web3.utils.toWei(1000000, 'ether'), from: accounts[0] })
after the deploy successfully we are not able to buyTokens. we are getting error.
Transaction: 0x57b96ee4ad13929502f7e0215103f1ed17f169c6fda1ba835e7da81b8d233b68 exited with an error (status 0). Reason given: SafeERC20: low-level call failed.
Please check that the transaction:
- satisfies all conditions set by Solidity require
statements.
- does not trigger a Solidity revert
statement.
Please check that the code. and please let me know if any correction is there. why getting this error