Hello!
For my tests I created 3 tokens ( SimpleToken.sol - from this link: https://forum.openzeppelin.com/t/simple-erc20-crowdsale/4863/1v)
They differ only with decimal places.
- First token has 8 decimals - not working with SimpleCrowdsale.sol
Token: https://ropsten.etherscan.io/token/0x67ca631789d7535fe9c68868d7d124377559e6ee
Contract: https://ropsten.etherscan.io/address/0x95326ebc1cd9429d53fad96fa338b1da48c7072e
You can test it. Just send some ether and You will NOT receive tokens.
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.5;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20Detailed.sol";
/**
* @title SimpleToken
* @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` functions.
*/
contract Token is Context, ERC20, ERC20Detailed {
/**
* @dev Constructor that gives _msgSender() all of existing tokens.
*/
constructor(
string memory name,
string memory symbol,
uint256 initialSupply
) public ERC20Detailed(name, symbol, 8) {
_mint(_msgSender(), initialSupply);
}
}
- Second token has 12 decimals - not working with SimpleCrowdsale.sol
Token: https://ropsten.etherscan.io/token/0xd75f93a9edddce751f0e028b69fc242b87322a89
Contract: https://ropsten.etherscan.io/address/0xe0f3a78268d438cb0aae16c851581914991f39a4
You can test it. Just send some ether and You will NOT receive tokens.
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.5;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20Detailed.sol";
/**
* @title SimpleToken
* @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` functions.
*/
contract Token is Context, ERC20, ERC20Detailed {
/**
* @dev Constructor that gives _msgSender() all of existing tokens.
*/
constructor(
string memory name,
string memory symbol,
uint256 initialSupply
) public ERC20Detailed(name, symbol, 12) {
_mint(_msgSender(), initialSupply);
}
}
- Third token has 18 decimals - working with SimpleCrowdsale.sol
Token: https://ropsten.etherscan.io/token/0xdfd2a35bcd73a2aa1652f90c0e8844f89c3946c3
Contract: https://ropsten.etherscan.io/address/0xea8deb636ffae28a819f2896ba6f93cc93fdb613
You can test it. Just send some ether and You will receive tokens.
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.5;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/token/ERC20/ERC20Detailed.sol";
/**
* @title SimpleToken
* @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` functions.
*/
contract Token is Context, ERC20, ERC20Detailed {
/**
* @dev Constructor that gives _msgSender() all of existing tokens.
*/
constructor(
string memory name,
string memory symbol,
uint256 initialSupply
) public ERC20Detailed(name, symbol, 18) {
_mint(_msgSender(), initialSupply);
}
}
SimpleCrowdsale.sol
// contracts/SimpleCrowdsale.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.5;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/Crowdsale.sol";
/**
* @title SimpleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
*/
contract SimpleCrowdsale is Crowdsale {
constructor(
uint256 rate,
address payable wallet,
IERC20 token
) public Crowdsale(rate, wallet, token) {}
}
Earlier solutions on the forum suggested that the problem was not enough tokens on the contract.
I have tested it and it is not a problem.
I have a lot of test tokens on each contract, but only one works - with 18 decimals, why?
For my tests i used SimpleToken.sol and SimpleCrowdsale.sol from this link: Simple ERC20 Crowdsale
For my test I used remix.ethereum.org
Please help!