3 questions:
Is this code secure or hackable in any sort of way?
Only the smart contract creator address is allowed to mint token right?
Is Pausable strictly necessary?
Thank you very much.
I was curious about your imports showing ./lib/oz/contracts/..
I don't know what your setup is like, though I would recommend following the Usage documentation.
Regards your questions:
Is this code secure or hackable in any sort of way?
You should do appropriate testing and auditing (assuming your token has potential value).
There was a recent question on this in the forum that would be worth reading (also links for testing and auditing):
Only the smart contract creator address is allowed to mint token right?
In your current CappedToken code, the deployer of the contract is the only minter.
ERC20Capped extends ERC20Mintable which at construction, the deployer of the contract is the only minter.
Is Pausable strictly necessary?
It really depends what functionality you need. See the ERC20Pausable API documentation:
ERC20Pausable
Useful if you want to stop trades until the end of a crowdsale, or have an emergency switch for freezing all token transfers in the event of a large bug.
For a simple token, depending on your requirements, you may not need it to be pausable or even potentially even mintable.
Based on the SimpleToken example you could have something like the following where the total supply of tokens is minted to the deployer of the contract, with no functionality to mint additional tokens.
As always, you should do appropriate testing and auditing on your smart contracts.
SimpleToken.sol
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/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 SimpleToken is ERC20, ERC20Detailed {
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
_mint(msg.sender, 10000 * (10 ** uint256(decimals())));
}
}
Thank you very much @abcoathup you are the best. In your last SimpleToken.sol example the contract creator is not allowed to mint more coins even though SimpleToken is not Capped? Thank you
In the SimpleToken example there is no public function to mint tokens.
Tokens are only minted in the constructor using the internal _mint function.
The deployer of the contract has no specific role. The only thing special about the deployer of the contract is that the constructor mints the total supply of tokens to them.
Feel free to ask all the questions that you need.
As always, you should do appropriate testing and auditing on your smart contracts.
Hello @abcoathup. Yes I’ve tried with truffle… Today I’ll create the topic because I’m not totally sure about some steps. Thank you very much for your help.