Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC20 token template using OpenZeppelin ERC20 implementation #164

Open
abcoathup opened this issue Dec 6, 2019 · 9 comments
Open

Add ERC20 token template using OpenZeppelin ERC20 implementation #164

abcoathup opened this issue Dec 6, 2019 · 9 comments
Assignees
Labels
feature-request New feature or request

Comments

@abcoathup
Copy link
Contributor

Summary

Add ERC20 token template using OpenZeppelin ERC20 implementation

Motivation

https://studio.ethereum.org/ will likely be the entry point for many new developers to the space.

Whilst an example of how to implement a token (currently called coin) is useful for developers to understand that it is primarily a list of addresses and balances, it may be beneficial to show how to appropriately inherit from OpenZeppelin Contracts implementation of ERC20.

Describe alternatives you've considered

The alternative is to provide some guidance in the README for the coin template that developers could inherit from OpenZeppelin Contracts ERC20 implementation.

Additional context

The token could be as simple as pre-assigning all tokens to the creator of the contract.

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/GSN/Context.sol";
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 Context, ERC20, ERC20Detailed {

    /**
     * @dev Constructor that gives _msgSender() all of existing tokens.
     */
    constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
        _mint(_msgSender(), 10000 * (10 ** uint256(decimals())));
    }
}

Disclosure: I am the Community Manager at OpenZeppelin

@ChrisChinchilla
Copy link
Contributor

This tutorial was intentionally designed to follow the example in the Solidity docs - https://solidity.readthedocs.io/en/v0.5.13/introduction-to-smart-contracts.html#subcurrency-example which is in turn a simplified version of the open zeppelin ERC-20, which we also did intentionally to keep it simpler for new developers.

I also think that for this "first step" covering imports and inheritance etc is way to complex, which is why we saved it for the later tutorials.

We are going to update all the tutorials soon, so maybe we'll think about the connections between them a little better in that review (#162)

PS. There were Zeppelin people involved in this project from early days.

@abcoathup
Copy link
Contributor Author

I like the progression starting with Hello World.

I was thinking that an ERC20 template could sit between Coin and NFTPizza.

@ChrisChinchilla
Copy link
Contributor

Yeah, that's a fair point, and I think was always at the back of my mind anyway.

And nice to meet a fellow Melburnian 🇦🇺

@ChrisChinchilla ChrisChinchilla self-assigned this Dec 16, 2019
@abcoathup
Copy link
Contributor Author

@ChrisChinchilla

Let me know if you need a simple ERC20 token that inherits from the OpenZeppelin implementation:
https://docs.openzeppelin.com/contracts/2.x/api/token/erc20

Also 👋 from the Melbourne suburbs. 🇦🇺

@javier-tarazaga
Copy link
Contributor

javier-tarazaga commented Jan 20, 2020

@abcoathup @ChrisChinchilla imo this is really needed. People might have no idea what ERC-20 might be though, so maybe we can find a better name for it?

P.S: Together with the Hellow World, the ERC-20 template was the most used template in Superblocks Lab in the past (by far).

@javier-tarazaga
Copy link
Contributor

@samajammin what about including some template to demonstrate this case? It is an easy way to demonstrate how do you actually can create a tradable token/coin/asset or whatever we consider naming it.

@javier-tarazaga javier-tarazaga added the feature-request New feature or request label Jan 23, 2020
@ChrisChinchilla
Copy link
Contributor

Was always on the list. When I've updated the existing ones, I'll get to it. And probably make a video to match this tutorial too as it's still "beginner"

@samajammin
Copy link
Collaborator

samajammin commented Jan 23, 2020

@javier-tarazaga does Studio support the ability to inspect the contracts it's inheriting from? If it's not possible, I agree with Chris that adding imports & inheritance risks creating too much confusion for new developers. There'd be no obvious/easy way to view the source code.

That said, I'm a proponent of updating the Coin example to be a full ERC-20 implementation. It's clear by the search volume it yields, there's a ton of buzz around ERC-20 as a concept & for me personally, seeing the code of the ERC-20 was one of my major "magic" moments with Ethereum. "Oh, an ERC-20 token is really this simple!?". Small anecdotal evidence but I've spoken with several other Ethereum developers who have shared this sentiment.

@javier-tarazaga
Copy link
Contributor

@samajammin I would prior then this for the next batch of things to change.

And answering your question, yes you can always see the code of the smart contract imported atm. You can't navigate directly from within the editor BUT all dependencies are always part of your file system tree, so they are always available to inspect. In the case of OZ dependencies, they are under the fake "node_modules" folder atm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants