SRC-20: Fungible token standard

So after some discussion last week about this with some fuel contributors, we were leaning towards something like the following as far as the abi goes, which is pretty much what @david originally proposed:

abi Token {
    #[storage(read)]
    fn total_supply() -> U256;
    fn decimals() -> u8;
    fn name() -> str[64];
    fn symbol() -> str[32];
}

Any other functions would be part of some optional add-on abis, i.e: mint, burn, etc… and these would also need to be specified in a standard way.

A return type of U256 for total_supply would support tokens with either very large supplies or high precision needs(18 decimals for example), but most tokens could probably be fine 9 decimals precision and storing the total supply as a u64 (and just casting to a U256 when returning).

name and symbol are tricky as the support for dynamic strings in Sway is not implemented yet. I think using static sized strings for these and just padding the strings with spaces to the required size is fine, for example: const SYMBOL: str[32] = "MYTKN ";.
It’s a little hacky but gets the job done for now and the frontend can easily trim the whitespace.

Speak up if you have any thoughts, questions or concerns with this approach, as nothing is written in stone yet :slight_smile:

Also, as much as the dev in me appreciates the SRC prefix, I wonder if we should consider using FRC for Fuel, as there will likely be other languages targeting the Fuel VM meaning the standard should to be higher level than just Sway. :thinking:

cc @david @fuel

1 Like