Super simple token with Open Zeppelin

Hi @Michael,

Welcome to the community :wave:

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:

  1. 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):

  1. 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.

  1. 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())));
    }
}
1 Like