FuelLabs/sway-standards

SRC-721; Non-Fungible Token Standard

bitzoic opened this issue · 1 comments

Abstract

The following standard allows for the implementation of a standard API for Native Non-Fungible Tokens (NFT) using the Sway Language. This standard provides basic functionality as well as on-chain metadata for other applications to use.

A Non-Fungible Token is a unique token that has an identifier that distinguishes itself from other tokens within the same token contract. These tokens are not fungible with one another and may contain metadata or other traits giving them distinctive characteristics.

Some common applications of an NFT include artwork/collectibles, DeFi short positions, deeds, and more.

Motivation

A standard interface for Non-Fungible Tokens on Fuel allows external applications to interact with each token individually, whether that be decentralized exchanges, wallets, or Fuel's Scripts and Predicates.

Prior Art

The SRC-721 Non-Fungible Token Standard naming pays homage to the ERC-721 Non-Fungible Token Standard seen on Ethereum.

There has been a discussion of the Non-Fungile Token Standard on the Fuel Forum. This discussion can be found here.

There has also been a Non-Fungile Token Standard implementation added to the Sway-Libs repository before the creation of the Sway-Standards repository. The introduction of this standard in the Sway-Standards repository will deprecate the Sway-Libs Non-Fungible Token Standard.

Specification

The Non-Fungible Token Standard inherits the specification and functionality from the SRC-20 standard. Non-Fungible Tokens on Fuel are Native Assets.

Restrictions

  • Non-Fungible Tokens SHALL have a total supply of one per asset.
  • Non-Fungible Tokens SHALL have a decimal of 0u8.

Rationale

As the SRC-721 Fungible Token Standard leverages Native Assets on Fuel, we do not require the implementation of certain functions such as transfer. This is done directly within the FuelVM and there is no smart contract that requires updating of balances. As Fuel is UTXO based, any transfer events may be indexed on transaction receipts.

Following this, we have omitted the inclusion of any transfer functions or events. The provided specification outlines only the required functions and events to implement fully functional Non-Fungible tokens on the Fuel Network. Additional functionality and properties may be added as needed.

Backwards Compatibility

This standard extends the SRC-20 standard.

Security Considerations

This standard does not introduce any security concerns, as it does not call external contracts, nor does it define any mutations of the contract state.

Example ABI

abi MyNFT {
    #[storage(read)]
    fn total_supply(asset: b256) -> u64;
    #[storage(read)]
    fn total_assets() -> u64;
    fn decimals(asset: b256) -> u8;
    #[storage(read)]
    fn name(asset: b256) -> String;
    #[storage(read)]
    fn symbol(asset: b256) -> String;
}

This draft standard is to be released as v0.1.

This issue has been closed in favor of #1 with applied restrictions.