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

feat: proposed fungible token trait #5

Merged
merged 17 commits into from
Sep 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion sips/sip-010/sip-010-fungible-token-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@ The fungible token trait, `ft-trait`, has a few methods:

Transfer the fungible token from the sender of this transaction to the recipient. The `amount` is an unsigned integer. It is recommended that implementing contracts use the built-in `ft-transfer` Clarity method. If the sender does not have enough tokens to complete the transaction, the transaction should abort and return an `(err uint)`.

This method must be defined with `define-public`, as it alters state, and should be externally callable.

### Name

`(name () (response (string-ascii 32) uint))`

Return a human-readable name for the contract, such as "CoolPoints", etc.
hstove marked this conversation as resolved.
Show resolved Hide resolved

This method should be defined as read-only, i.e. `define-read-only`.
jcnelson marked this conversation as resolved.
Show resolved Hide resolved

### Symbol

`(symbol () (response (string-ascii 32) uint))`
hstove marked this conversation as resolved.
Show resolved Hide resolved

Return a symbol that allows for a shorter representation of your token. This is sometimes referred to as a "ticker". Examples: "STX", "COOL", etc. Typically, your token could be referred to as $SYMBOL when referencing it in writing.
hstove marked this conversation as resolved.
Show resolved Hide resolved

This method should be defined as read-only, i.e. `define-read-only`.

### Decimals

`(decimals () (response uint uint))`
hstove marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -55,18 +61,24 @@ The number of decimal places in your token. All fungible token balances must be

As another example, if your token has 4 decimals, and the `balance-of` a particular user returns `100345000`, wallets and exchanges would likely represent that value as `10034.5`.

This method should be defined as read-only, i.e. `define-read-only`.

### Balance of

`(balance-of (principal) (response uint uint))`
hstove marked this conversation as resolved.
Show resolved Hide resolved

Return the balance of a particular principal (also known as "address" or "account"). Implementations should typically use the built-in Clarity method `ft-get-balance`.
jcnelson marked this conversation as resolved.
Show resolved Hide resolved

This method should be defined as read-only, i.e. `define-read-only`.

### Total supply

`(total-supply () (response uint uint))`

Return the total supply of this token. Implementations should typically use the built-in Clarity method `ft-get-supply`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What to put if total-supply is unlimited?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example of a token with unlimited liquid supply?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the supply may be unlimited, but this is meant to be the current supply if you sum all the addresses that contain the token. So always a specific value the token should keep track of


This method should be defined as read-only, i.e. `define-read-only`.

## Trait implementation

An implementation of the proposed trait is provided below.
Expand Down Expand Up @@ -105,7 +117,7 @@ Credit for the work behind this proposal belongs to [@psq](https://github.com/ps

## Implementing in wallets and other applications

Developers who with to interact with a fungible token contract should first be provided, or keep track of, various different fungible token implementations. When validating a fungible token contract, they should fetch the interface and/or source code for that contract. If the contract implements the trait, then the wallet can use this standard's contract interface for making transfers and getting balances.
Developers who wish to interact with a fungible token contract should first be provided, or keep track of, various different fungible token implementations. When validating a fungible token contract, they should fetch the interface and/or source code for that contract. If the contract implements the trait, then the wallet can use this standard's contract interface for making transfers and getting balances.

### Use of post conditions

Expand Down