diff --git a/README.md b/README.md index c6b4a79..68a792c 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,11 @@ If you don't find what you're looking for, feel free to create an issue and prop ### Native Assets -- [SRC-20; Token Standard](./standards/src20-token/) defines the implementation of a standard API for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) using the Sway Language. +- [SRC-20; Native Asset Standard](./standards/src20-native-asset/) defines the implementation of a standard API for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) using the Sway Language. - [SRC-3; Mint and Burn](./standards/src3-mint-burn/) is used to enable mint and burn functionality for Native Assets. - [SRC-7; Arbitrary Asset Metadata Standard](./standards/src7-metadata/) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). - [SRC-9; Metadata Keys Standard](./standards/src9-metadata-keys/) is used to store standardized metadata keys for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) in combination with the SRC-7 standard. -- [SRC-6; Vault Standard](./standards/src6-vault/) defines the implementation of a standard API for token vaults developed in Sway. +- [SRC-6; Vault Standard](./standards/src6-vault/) defines the implementation of a standard API for asset vaults developed in Sway. ### Access Control @@ -68,7 +68,7 @@ You may then import your desired standard in your Sway Smart Contract as so: use standard::; ``` -For example, to import the SRC-20 Token Standard use the following statements in your `Forc.toml` and Sway Smart Contract file respectively: +For example, to import the SRC-20 Native Asset Standard use the following statements in your `Forc.toml` and Sway Smart Contract file respectively: ```rust src20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.0" } @@ -82,13 +82,13 @@ use src20::SRC20; Minimal example implementations for every standard can be found in the [`examples/`](./examples/) folder. -#### SRC-20; Token Standard Examples +#### SRC-20; Native Asset Standard Examples -##### - [Single Native Assset](./examples/src20-token/single_asset/src/single_asset.sw) +##### - [Single Native Assset](./examples/src20-native-asset/single_asset/src/single_asset.sw) Example of the SRC-20 implementation where a contract contains a single asset with one `SubId`. This implementation is recommended for users that intend to deploy a single asset with their contract. -##### - [Multi Native Asset](./examples/src20-token/multi_asset/src/multi_asset.sw) +##### - [Multi Native Asset](./examples/src20-native-asset/multi_asset/src/multi_asset.sw) Example of the SRC-20 implementation where a contract contains multiple assets with differing `SubId`s. This implementation is recommended for users that intend to deploy multiple assets with their contract. @@ -114,15 +114,15 @@ Example of the SRC-5 implementation where a contract has an owner set at compile #### SRC-6; Vault Standard Examples -##### [Multi Token Vault](./examples/src6-vault/multi_token_vault/) +##### [Multi Asset Vault](./examples/src6-vault/multi_asset_vault/) A basic implementation of the vault standard that supports any number of sub vaults being created for every AssetId. -##### [Single Token Vault](./examples/src6-vault/single_token_vault/) +##### [Single Asset Vault](./examples/src6-vault/single_asset_vault/) A basic implementation of the vault standard demonstrating how to restrict deposits and withdrawals to a single AssetId. -##### [Single Token Single Sub Vault](./examples/src6-vault/single_token_single_sub_vault/) +##### [Single Asset Single Sub Vault](./examples/src6-vault/single_asset_single_sub_vault/) A basic implementation of the vault standard demonstrating how to restrict deposits and withdrawals to a single AssetId, and to a single Sub vault. diff --git a/examples/Forc.toml b/examples/Forc.toml index be17827..5bfe0fc 100644 --- a/examples/Forc.toml +++ b/examples/Forc.toml @@ -6,6 +6,6 @@ members = [ "src5-ownership/uninitialized_example", "src7-metadata/single_asset", "src7-metadata/multi_asset", - "src20-token/single_asset", - "src20-token/multi_asset", + "src20-native-asset/single_asset", + "src20-native-asset/multi_asset", ] diff --git a/examples/src20-token/multi_asset/Forc.toml b/examples/src20-native-asset/multi_asset/Forc.toml similarity index 70% rename from examples/src20-token/multi_asset/Forc.toml rename to examples/src20-native-asset/multi_asset/Forc.toml index 6291a77..adf301b 100644 --- a/examples/src20-token/multi_asset/Forc.toml +++ b/examples/src20-native-asset/multi_asset/Forc.toml @@ -5,4 +5,4 @@ license = "Apache-2.0" name = "multi_src20_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } diff --git a/examples/src20-token/multi_asset/src/multi_asset.sw b/examples/src20-native-asset/multi_asset/src/multi_asset.sw similarity index 95% rename from examples/src20-token/multi_asset/src/multi_asset.sw rename to examples/src20-native-asset/multi_asset/src/multi_asset.sw index 54852a6..635cc4f 100644 --- a/examples/src20-token/multi_asset/src/multi_asset.sw +++ b/examples/src20-native-asset/multi_asset/src/multi_asset.sw @@ -4,9 +4,9 @@ use src20::SRC20; use std::{hash::Hash, storage::storage_string::*, string::String}; storage { - /// The total number of distinguishable tokens minted by this contract. + /// The total number of distinguishable assets minted by this contract. total_assets: u64 = 0, - /// The total supply of tokens for a specific asset minted by this contract. + /// The total supply of coins for a specific asset minted by this contract. total_supply: StorageMap = StorageMap {}, /// The name of a specific asset minted by this contract. name: StorageMap = StorageMap {}, @@ -47,7 +47,7 @@ impl SRC20 for Contract { storage.total_assets.read() } - /// Returns the total supply of tokens for an asset. + /// Returns the total supply of coins for an asset. /// /// # Arguments /// diff --git a/examples/src20-token/single_asset/Forc.toml b/examples/src20-native-asset/single_asset/Forc.toml similarity index 71% rename from examples/src20-token/single_asset/Forc.toml rename to examples/src20-native-asset/single_asset/Forc.toml index 3fb9050..dc8c7a0 100644 --- a/examples/src20-token/single_asset/Forc.toml +++ b/examples/src20-native-asset/single_asset/Forc.toml @@ -5,4 +5,4 @@ license = "Apache-2.0" name = "single_src20_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } diff --git a/examples/src20-token/single_asset/src/single_asset.sw b/examples/src20-native-asset/single_asset/src/single_asset.sw similarity index 96% rename from examples/src20-token/single_asset/src/single_asset.sw rename to examples/src20-native-asset/single_asset/src/single_asset.sw index 50506ed..610c536 100644 --- a/examples/src20-token/single_asset/src/single_asset.sw +++ b/examples/src20-native-asset/single_asset/src/single_asset.sw @@ -4,12 +4,12 @@ use src20::SRC20; use std::{call_frames::contract_id, string::String}; configurable { - /// The total supply of tokens for the asset minted by this contract. + /// The total supply of coins for the asset minted by this contract. TOTAL_SUPPLY: u64 = 100_000_000, /// The decimals of the asset minted by this contract. DECIMALS: u8 = 9u8, /// The name of the asset minted by this contract. - NAME: str[7] = __to_str_array("MyToken"), + NAME: str[7] = __to_str_array("MyAsset"), /// The symbol of the asset minted by this contract. SYMBOL: str[5] = __to_str_array("MYTKN"), } @@ -41,7 +41,7 @@ impl SRC20 for Contract { 1 } - /// Returns the total supply of tokens for the asset. + /// Returns the total supply of coins for the asset. /// /// # Arguments /// diff --git a/examples/src3-mint-burn/multi_asset/Forc.toml b/examples/src3-mint-burn/multi_asset/Forc.toml index 2283191..60a1f47 100644 --- a/examples/src3-mint-burn/multi_asset/Forc.toml +++ b/examples/src3-mint-burn/multi_asset/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "multi_src3_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src3 = { path = "../../../standards/src3-mint-burn" } diff --git a/examples/src3-mint-burn/multi_asset/src/multi_asset.sw b/examples/src3-mint-burn/multi_asset/src/multi_asset.sw index f1a1a16..043e188 100644 --- a/examples/src3-mint-burn/multi_asset/src/multi_asset.sw +++ b/examples/src3-mint-burn/multi_asset/src/multi_asset.sw @@ -35,13 +35,13 @@ storage { } impl SRC3 for Contract { - /// Unconditionally mints new tokens using the `sub_id` sub-identifier. + /// Unconditionally mints new assets using the `sub_id` sub-identifier. /// /// # Arguments /// - /// * `recipient`: [Identity] - The user to which the newly minted tokens are transferred to. - /// * `sub_id`: [SubId] - The sub-identifier of the newly minted token. - /// * `amount`: [u64] - The quantity of tokens to mint. + /// * `recipient`: [Identity] - The user to which the newly minted asset is transferred to. + /// * `sub_id`: [SubId] - The sub-identifier of the newly minted asset. + /// * `amount`: [u64] - The quantity of coins to mint. /// /// # Number of Storage Accesses /// @@ -81,12 +81,12 @@ impl SRC3 for Contract { mint_to(recipient, sub_id, amount); } - /// Unconditionally burns tokens sent with the `sub_id` sub-identifier. + /// Unconditionally burns assets sent with the `sub_id` sub-identifier. /// /// # Arguments /// - /// * `sub_id`: [SubId] - The sub-identifier of the token to burn. - /// * `amount`: [u64] - The quantity of tokens to burn. + /// * `sub_id`: [SubId] - The sub-identifier of the asset to burn. + /// * `amount`: [u64] - The quantity of coins to burn. /// /// # Number of Storage Accesses /// @@ -95,7 +95,7 @@ impl SRC3 for Contract { /// /// # Reverts /// - /// * When the transaction did not include at least `amount` tokens. + /// * When the transaction did not include at least `amount` coins. /// * When the asset included in the transaction does not have the SubId `sub_id`. /// /// # Examples diff --git a/examples/src3-mint-burn/single_asset/Forc.toml b/examples/src3-mint-burn/single_asset/Forc.toml index 6278faa..b7d6e53 100644 --- a/examples/src3-mint-burn/single_asset/Forc.toml +++ b/examples/src3-mint-burn/single_asset/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "single_src3_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src3 = { path = "../../../standards/src3-mint-burn" } diff --git a/examples/src3-mint-burn/single_asset/src/single_asset.sw b/examples/src3-mint-burn/single_asset/src/single_asset.sw index 874d0c6..a57452f 100644 --- a/examples/src3-mint-burn/single_asset/src/single_asset.sw +++ b/examples/src3-mint-burn/single_asset/src/single_asset.sw @@ -20,7 +20,7 @@ configurable { /// The decimals of the asset minted by this contract. DECIMALS: u8 = 9u8, /// The name of the asset minted by this contract. - NAME: str[7] = __to_str_array("MyToken"), + NAME: str[7] = __to_str_array("MyAsset"), /// The symbol of the asset minted by this contract. SYMBOL: str[5] = __to_str_array("MYTKN"), } @@ -31,13 +31,13 @@ storage { } impl SRC3 for Contract { - /// Unconditionally mints new tokens using the default SubId. + /// Unconditionally mints new assets using the default SubId. /// /// # Arguments /// - /// * `recipient`: [Identity] - The user to which the newly minted tokens are transferred to. + /// * `recipient`: [Identity] - The user to which the newly minted asset is transferred to. /// * `sub_id`: [SubId] - The default SubId. - /// * `amount`: [u64] - The quantity of tokens to mint. + /// * `amount`: [u64] - The quantity of coins to mint. /// /// # Number of Storage Accesses /// @@ -70,12 +70,12 @@ impl SRC3 for Contract { mint_to(recipient, DEFAULT_SUB_ID, amount); } - /// Unconditionally burns tokens sent with the default SubId. + /// Unconditionally burns assets sent with the default SubId. /// /// # Arguments /// /// * `sub_id`: [SubId] - The default SubId. - /// * `amount`: [u64] - The quantity of tokens to burn. + /// * `amount`: [u64] - The quantity of coins to burn. /// /// # Number of Storage Accesses /// @@ -85,7 +85,7 @@ impl SRC3 for Contract { /// # Reverts /// /// * When the `sub_id` is not the default SubId. - /// * When the transaction did not include at least `amount` tokens. + /// * When the transaction did not include at least `amount` coins. /// * When the transaction did not include the asset minted by this contract. /// /// # Examples diff --git a/examples/src6-vault/multi_token_vault/Forc.toml b/examples/src6-vault/multi_token_vault/Forc.toml index b88b6fe..a1a6032 100644 --- a/examples/src6-vault/multi_token_vault/Forc.toml +++ b/examples/src6-vault/multi_token_vault/Forc.toml @@ -2,8 +2,8 @@ authors = ["Fuel Labs "] entry = "main.sw" license = "Apache-2.0" -name = "multi_token_vault" +name = "multi_asset_vault" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src6 = { path = "../../../standards/src6-vault" } diff --git a/examples/src6-vault/multi_token_vault/src/main.sw b/examples/src6-vault/multi_token_vault/src/main.sw index c5f34bb..f9df4ac 100644 --- a/examples/src6-vault/multi_token_vault/src/main.sw +++ b/examples/src6-vault/multi_token_vault/src/main.sw @@ -238,7 +238,7 @@ pub fn _burn(asset_id: AssetId, vault_sub_id: SubId, amount: u64) { require( this_balance(asset_id) >= amount, - "BurnError::NotEnoughTokens", + "BurnError::NotEnoughCoins", ); // If we pass the check above, we can assume it is safe to unwrap. let supply = storage.total_supply.get(asset_id).try_read().unwrap(); diff --git a/examples/src6-vault/single_token_single_sub_vault/Forc.toml b/examples/src6-vault/single_token_single_sub_vault/Forc.toml index f5f91f1..dc19ccf 100644 --- a/examples/src6-vault/single_token_single_sub_vault/Forc.toml +++ b/examples/src6-vault/single_token_single_sub_vault/Forc.toml @@ -2,8 +2,8 @@ authors = ["Fuel Labs "] entry = "main.sw" license = "Apache-2.0" -name = "single_token_single_sub_vault" +name = "single_asset_single_sub_vault" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src6 = { path = "../../../standards/src6-vault" } diff --git a/examples/src6-vault/single_token_single_sub_vault/src/main.sw b/examples/src6-vault/single_token_single_sub_vault/src/main.sw index 7ed8349..7668ed9 100644 --- a/examples/src6-vault/single_token_single_sub_vault/src/main.sw +++ b/examples/src6-vault/single_token_single_sub_vault/src/main.sw @@ -21,7 +21,7 @@ use src20::SRC20; configurable { /// The only asset that can be deposited and withdrawn from this vault. - ACCEPTED_TOKEN: AssetId = BASE_ASSET_ID, + ACCEPTED_ASSET: AssetId = BASE_ASSET_ID, /// The only sub vault that can be deposited and withdrawn from this vault. ACCEPTED_SUB_VAULT: SubId = ZERO_B256, PRE_CALCULATED_SHARE_VAULT_SUB_ID: SubId = 0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b, @@ -43,7 +43,7 @@ impl SRC6 for Contract { require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id"); let underlying_asset = msg_asset_id(); - require(underlying_asset == ACCEPTED_TOKEN, "INVALID_ASSET_ID"); + require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID"); let asset_amount = msg_amount(); require(asset_amount != 0, "ZERO_ASSETS"); @@ -77,7 +77,7 @@ impl SRC6 for Contract { underlying_asset: AssetId, vault_sub_id: SubId, ) -> u64 { - require(underlying_asset == ACCEPTED_TOKEN, "INVALID_ASSET_ID"); + require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID"); require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id"); let shares = msg_amount(); @@ -109,7 +109,7 @@ impl SRC6 for Contract { #[storage(read)] fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64 { - if underlying_asset == ACCEPTED_TOKEN && vault_sub_id == ACCEPTED_SUB_VAULT { + if underlying_asset == ACCEPTED_ASSET && vault_sub_id == ACCEPTED_SUB_VAULT { // In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable. storage.managed_assets.read() } else { @@ -123,7 +123,7 @@ impl SRC6 for Contract { underlying_asset: AssetId, vault_sub_id: SubId, ) -> Option { - if underlying_asset == ACCEPTED_TOKEN { + if underlying_asset == ACCEPTED_ASSET { // This is the max value of u64 minus the current managed_assets. Ensures that the sum will always be lower than u64::MAX. Some(u64::max() - storage.managed_assets.read()) } else { @@ -133,7 +133,7 @@ impl SRC6 for Contract { #[storage(read)] fn max_withdrawable(underlying_asset: AssetId, vault_sub_id: SubId) -> Option { - if underlying_asset == ACCEPTED_TOKEN { + if underlying_asset == ACCEPTED_ASSET { // In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable. Some(storage.managed_assets.read()) } else { @@ -210,7 +210,7 @@ pub fn _burn(asset_id: AssetId, amount: u64) { require( this_balance(asset_id) >= amount, - "BurnError::NotEnoughTokens", + "BurnError::NotEnoughCoins", ); // If we pass the check above, we can assume it is safe to unwrap. let supply = storage.total_supply.read(); diff --git a/examples/src6-vault/single_token_vault/Forc.toml b/examples/src6-vault/single_token_vault/Forc.toml index 1730994..a6ecc74 100644 --- a/examples/src6-vault/single_token_vault/Forc.toml +++ b/examples/src6-vault/single_token_vault/Forc.toml @@ -2,8 +2,8 @@ authors = ["Fuel Labs "] entry = "main.sw" license = "Apache-2.0" -name = "single_token_vault" +name = "single_asset_vault" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src6 = { path = "../../../standards/src6-vault" } diff --git a/examples/src6-vault/single_token_vault/src/main.sw b/examples/src6-vault/single_token_vault/src/main.sw index 9a650fe..61168f9 100644 --- a/examples/src6-vault/single_token_vault/src/main.sw +++ b/examples/src6-vault/single_token_vault/src/main.sw @@ -42,7 +42,7 @@ storage { configurable { /// The only asset that can be deposited and withdrawn from this vault. - ACCEPTED_TOKEN: AssetId = BASE_ASSET_ID, + ACCEPTED_ASSET: AssetId = BASE_ASSET_ID, } impl SRC6 for Contract { @@ -52,7 +52,7 @@ impl SRC6 for Contract { let asset_amount = msg_amount(); let underlying_asset = msg_asset_id(); - require(underlying_asset == ACCEPTED_TOKEN, "INVALID_ASSET_ID"); + require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID"); let (shares, share_asset, share_asset_vault_sub_id) = preview_deposit(underlying_asset, vault_sub_id, asset_amount); require(asset_amount != 0, "ZERO_ASSETS"); @@ -126,7 +126,7 @@ impl SRC6 for Contract { #[storage(read)] fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64 { - if underlying_asset == ACCEPTED_TOKEN { + if underlying_asset == ACCEPTED_ASSET { let vault_share_asset = vault_asset_id(underlying_asset, vault_sub_id).0; // In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable. managed_assets(vault_share_asset) @@ -141,7 +141,7 @@ impl SRC6 for Contract { underlying_asset: AssetId, vault_sub_id: SubId, ) -> Option { - if underlying_asset == ACCEPTED_TOKEN { + if underlying_asset == ACCEPTED_ASSET { // This is the max value of u64 minus the current managed_assets. Ensures that the sum will always be lower than u64::MAX. Some(u64::max() - managed_assets(underlying_asset)) } else { @@ -151,7 +151,7 @@ impl SRC6 for Contract { #[storage(read)] fn max_withdrawable(underlying_asset: AssetId, vault_sub_id: SubId) -> Option { - if underlying_asset == ACCEPTED_TOKEN { + if underlying_asset == ACCEPTED_ASSET { // In this implementation total_assets and max_withdrawable are the same. However in case of lending out of assets, total_assets should be greater than max_withdrawable. Some(managed_assets(underlying_asset)) } else { @@ -259,7 +259,7 @@ pub fn _burn(asset_id: AssetId, vault_sub_id: SubId, amount: u64) { require( this_balance(asset_id) >= amount, - "BurnError::NotEnoughTokens", + "BurnError::NotEnoughCoins", ); // If we pass the check above, we can assume it is safe to unwrap. let supply = storage.total_supply.get(asset_id).try_read().unwrap(); diff --git a/examples/src7-metadata/multi_asset/Forc.toml b/examples/src7-metadata/multi_asset/Forc.toml index e1802fb..c503248 100644 --- a/examples/src7-metadata/multi_asset/Forc.toml +++ b/examples/src7-metadata/multi_asset/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "multi_src7_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src7 = { path = "../../../standards/src7-metadata" } diff --git a/examples/src7-metadata/single_asset/Forc.toml b/examples/src7-metadata/single_asset/Forc.toml index 66955e3..df2c9bc 100644 --- a/examples/src7-metadata/single_asset/Forc.toml +++ b/examples/src7-metadata/single_asset/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "single_src7_asset" [dependencies] -src20 = { path = "../../../standards/src20-token" } +src20 = { path = "../../../standards/src20-native-asset" } src7 = { path = "../../../standards/src7-metadata" } diff --git a/examples/src7-metadata/single_asset/src/single_asset.sw b/examples/src7-metadata/single_asset/src/single_asset.sw index 30091ab..ccd8572 100644 --- a/examples/src7-metadata/single_asset/src/single_asset.sw +++ b/examples/src7-metadata/single_asset/src/single_asset.sw @@ -6,12 +6,12 @@ use src20::SRC20; use std::{call_frames::contract_id, string::String}; configurable { - /// The total supply of tokens for the asset minted by this contract. + /// The total supply of coins for the asset minted by this contract. TOTAL_SUPPLY: u64 = 100_000_000, /// The decimals of the asset minted by this contract. DECIMALS: u8 = 9u8, /// The name of the asset minted by this contract. - NAME: str[7] = __to_str_array("MyToken"), + NAME: str[7] = __to_str_array("MyAsset"), /// The symbol of the asset minted by this contract. SYMBOL: str[5] = __to_str_array("MYTKN"), /// The metadata for the "social:x" key. diff --git a/standards/Forc.toml b/standards/Forc.toml index 93ba3af..7a30db4 100644 --- a/standards/Forc.toml +++ b/standards/Forc.toml @@ -5,5 +5,5 @@ members = [ "src6-vault", "src7-metadata", "src10-native-bridge", - "src20-token", + "src20-native-asset", ] diff --git a/standards/src10-native-bridge/README.md b/standards/src10-native-bridge/README.md index 8930a38..c62b7a0 100644 --- a/standards/src10-native-bridge/README.md +++ b/standards/src10-native-bridge/README.md @@ -38,7 +38,7 @@ The `register_token()` function compiles a message to be sent back to the canoni The `process_message()` function accepts incoming deposit messages from the canonical chain and issues the corresponding bridged asset. - This function MUST parse a message at the given `message_index` index. -- This function SHALL mint a token that follows the [SRC-8; Bridged Asset Standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_8). +- This function SHALL mint an asset that follows the [SRC-8; Bridged Asset Standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src8-bridged-asset). - This function SHALL issue a refund if there is an error in the bridging process. ### - `fn withdraw(to_address: b256, sub_id: SubId, gateway_contract: b256)` @@ -47,7 +47,7 @@ The `withdraw()` function accepts and burns a bridged Native Asset on Fuel and s - This function SHALL send a message to the `gateway_contract` contract to release the bridged tokens to the `to_address` address on the canonical chain. - This function MUST ensure the `sha256(contract_id(), sub_id)` digest matches the asset's `AssetId` sent in the transaction. -- This function SHALL burn all tokens sent in the transaction. +- This function SHALL burn all coins sent in the transaction. ### - `fn claim_refund(to_address: b256, token_address: b256, token_id: b256, gateway_contract: b256)` @@ -101,7 +101,7 @@ struct MessageData { ## Required Standards -Any contract that implements the SRC-10; Native Bridge Standard MUST implement the [SRC-8; Bridged Asset Standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_8) for all bridged assets. +Any contract that implements the SRC-10; Native Bridge Standard MUST implement the [SRC-8; Bridged Asset Standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src8-bridged-asset) for all bridged assets. # Rationale diff --git a/standards/src2-inline-docs/README.md b/standards/src2-inline-docs/README.md index 07c603f..643e3fb 100644 --- a/standards/src2-inline-docs/README.md +++ b/standards/src2-inline-docs/README.md @@ -337,9 +337,9 @@ pub fn only_owner(self, number: u64) -> bool { ## Struct Examples ```rust -/// Metadata that is tied to a token. +/// Metadata that is tied to an asset. pub struct NFTMetadata { - /// Represents the token ID of this NFT. + /// Represents the ID of this NFT. value: u64, } ``` @@ -347,7 +347,7 @@ pub struct NFTMetadata { ```rust /// Log of a bid. pub struct Bid { - /// The number of tokens that were bid. + /// The number of coins that were bid. amount: u64, /// The user which placed this bid. bidder: Identity, @@ -380,8 +380,8 @@ pub enum AccessError { ```rust storage { - /// The contract of the tokens which is to be distributed. - asset: Option = Option::None, + /// An asset which is to be distributed. + asset: Option = Option::None, /// Stores the ClaimState of users that have interacted with the Airdrop Distributor contract. /// /// # Additional Information diff --git a/standards/src20-native-asset/.docs/src-20-logo-dark-theme.png b/standards/src20-native-asset/.docs/src-20-logo-dark-theme.png new file mode 100644 index 0000000..5a81a7a Binary files /dev/null and b/standards/src20-native-asset/.docs/src-20-logo-dark-theme.png differ diff --git a/standards/src20-native-asset/.docs/src-20-logo-light-theme.png b/standards/src20-native-asset/.docs/src-20-logo-light-theme.png new file mode 100644 index 0000000..5cd3408 Binary files /dev/null and b/standards/src20-native-asset/.docs/src-20-logo-light-theme.png differ diff --git a/standards/src20-token/Forc.toml b/standards/src20-native-asset/Forc.toml similarity index 100% rename from standards/src20-token/Forc.toml rename to standards/src20-native-asset/Forc.toml diff --git a/standards/src20-token/README.md b/standards/src20-native-asset/README.md similarity index 63% rename from standards/src20-token/README.md rename to standards/src20-native-asset/README.md index 1441989..4c76c5c 100644 --- a/standards/src20-token/README.md +++ b/standards/src20-native-asset/README.md @@ -11,11 +11,11 @@ The following standard allows for the implementation of a standard API for [Nati # Motivation -A standard interface for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) on Fuel allows external applications to interact with the token, whether that be decentralized exchanges, wallets, or Fuel's [Scripts](https://docs.fuel.network/docs/sway/sway-program-types/scripts/) and [Predicates](https://docs.fuel.network/docs/sway/sway-program-types/predicates/). +A standard interface for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) on Fuel allows external applications to interact with the native asset, whether that be decentralized exchanges, wallets, or Fuel's [Scripts](https://docs.fuel.network/docs/sway/sway-program-types/scripts/) and [Predicates](https://docs.fuel.network/docs/sway/sway-program-types/predicates/). # Prior Art -The SRC-20 Token Standard naming pays homage to the [ERC-20 Token Standard](https://eips.ethereum.org/EIPS/eip-20) seen on Ethereum. While there is functionality we may use as a reference, it is noted that Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) are fundamentally different than Ethereum's tokens. +The SRC-20 Native Asset Standard naming pays homage to the [ERC-20 Token Standard](https://eips.ethereum.org/EIPS/eip-20) seen on Ethereum. While there is functionality we may use as a reference, it is noted that Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) are fundamentally different than Ethereum's tokens. There has been a discussion of the Fungile Token Standard on the [Fuel Forum](https://forum.fuel.network/). This discussion can be found [here](https://forum.fuel.network/t/src-20-fungible-token-standard/186). @@ -33,7 +33,7 @@ This function MUST return the total number of individual assets for a contract. ### `fn total_supply(asset: AssetId) -> Option` -This function MUST return the total supply of tokens for an asset. This function MUST return `Some` for any assets minted by the contract. +This function MUST return the total supply of coins for an asset. This function MUST return `Some` for any assets minted by the contract. ### `fn name(asset: AssetId) -> Option` @@ -45,20 +45,20 @@ This function must return the symbol of the asset, such as “ETH”. This funct ### `fn decimals(asset: AssetId) -> Option` -This function must return the number of decimals the asset uses - e.g. 8, which means to divide the token amount by 100000000 to get its user representation. This function MUST return `Some` for any assets minted by the contract. +This function must return the number of decimals the asset uses - e.g. 8, which means to divide the coin amount by 100000000 to get its user representation. This function MUST return `Some` for any assets minted by the contract. -## Non-Fungible Token Restrictions +## Non-Fungible Asset Restrictions -Non-Fungible Tokens (NFT) on Fuel are Native Assets and thus follow the same standard as Fungible Tokens with some restrictions. For a Native Asset on Fuel to be deemed an NFT, the following must be applied: +Non-Fungible Tokens (NFT) or Non-Fungible Assets on Fuel are Native Assets and thus follow the same standard as Fungible Native Assets with some restrictions. For a Native Asset on Fuel to be deemed an NFT, the following must be applied: -* Non-Fungible Tokens SHALL have a total supply of one per asset. -* Non-Fungible Tokens SHALL have a decimal of `0u8`. +* Non-Fungible Assets SHALL have a total supply of one per asset. +* Non-Fungible Assets SHALL have a decimal of `0u8`. # Rationale -As the SRC-20 Token Standard leverages Native Assets on Fuel, we do not require the implementation of certain functions such as transfer or approval. 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. +As the SRC-20 Native Asset Standard leverages Native Assets on Fuel, we do not require the implementation of certain functions such as transfer or approval. 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 tokens on the Fuel Network. Additional functionality and properties may be added as needed. +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 native assets on the Fuel Network. Additional functionality and properties may be added as needed. # Backwards Compatibility @@ -71,7 +71,7 @@ This standard does not introduce any security concerns, as it does not call exte # Example ABI ```rust -abi MyToken { +abi MyAsset { #[storage(read)] fn total_assets() -> u64; #[storage(read)] @@ -87,10 +87,10 @@ abi MyToken { # Example Implementation -## [Single Native Assset](../../examples/src20-token/single_asset/src/single_asset.sw) +## [Single Native Assset](../../examples/src20-native-asset/single_asset/src/single_asset.sw) Example of the SRC-20 implementation where a contract contains a single asset with one `SubId`. This implementation is recommended for users that intend to deploy a single asset with their contract. -## [Multi Native Asset](../../examples/src20-token/multi_asset/src/multi_asset.sw) +## [Multi Native Asset](../../examples/src20-native-asset/multi_asset/src/multi_asset.sw) Example of the SRC-20 implementation where a contract contains multiple assets with differing `SubId`s. This implementation is recommended for users that intend to deploy multiple assets with their contract. diff --git a/standards/src20-token/src/src20.sw b/standards/src20-native-asset/src/src20.sw similarity index 93% rename from standards/src20-token/src/src20.sw rename to standards/src20-native-asset/src/src20.sw index 68bf9e7..89cff77 100644 --- a/standards/src20-token/src/src20.sw +++ b/standards/src20-native-asset/src/src20.sw @@ -23,7 +23,7 @@ abi SRC20 { #[storage(read)] fn total_assets() -> u64; - /// Returns the total supply of tokens for an asset. + /// Returns the total supply of coins for an asset. /// /// # Arguments /// @@ -31,7 +31,7 @@ abi SRC20 { /// /// # Returns /// - /// * [Option] - The total supply of tokens for `asset`. + /// * [Option] - The total supply of coins for `asset`. /// /// # Examples /// @@ -99,7 +99,7 @@ abi SRC20 { /// /// # Additional Information /// - /// e.g. 8, means to divide the token amount by 100000000 to get its user representation. + /// e.g. 8, means to divide the coin amount by 100000000 to get its user representation. /// /// # Arguments /// diff --git a/standards/src20-token/.docs/src-20-logo-dark-theme.png b/standards/src20-token/.docs/src-20-logo-dark-theme.png deleted file mode 100644 index 84a9888..0000000 Binary files a/standards/src20-token/.docs/src-20-logo-dark-theme.png and /dev/null differ diff --git a/standards/src20-token/.docs/src-20-logo-light-theme.png b/standards/src20-token/.docs/src-20-logo-light-theme.png deleted file mode 100644 index 15908fc..0000000 Binary files a/standards/src20-token/.docs/src-20-logo-light-theme.png and /dev/null differ diff --git a/standards/src3-mint-burn/README.md b/standards/src3-mint-burn/README.md index 9d04875..a99ded2 100644 --- a/standards/src3-mint-burn/README.md +++ b/standards/src3-mint-burn/README.md @@ -1,14 +1,14 @@ # Abstract -The following standard enables the minting and burning of tokens for any fungible assets within the Sway Language. It seeks to define mint and burn functions defined separately from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. Any contract that implements the SRC-3 standard MUST implement the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +The following standard enables the minting and burning of native assets for any fungible assets within the Sway Language. It seeks to define mint and burn functions defined separately from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. Any contract that implements the SRC-3 standard MUST implement the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Motivation -The intent of this standard is to separate the extensions of minting and burning from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +The intent of this standard is to separate the extensions of minting and burning from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Prior Art -Minting and burning were initially added to the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +Minting and burning were initially added to the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Specification @@ -18,44 +18,44 @@ The following functions MUST be implemented to follow the SRC-3 standard: ### `fn mint(recipient: Identity, vault_sub_id: SubId, amount: u64)` -This function MUST mint `amount` tokens with sub-identifier `vault_sub_id` and transfer them to the `recipient`. +This function MUST mint `amount` coins with sub-identifier `vault_sub_id` and transfer them to the `recipient`. This function MAY contain arbitrary conditions for minting, and revert if those conditions are not met. ##### Arguments -* `recipient` - The `Identity` to which the newly minted tokens are transferred to. +* `recipient` - The `Identity` to which the newly minted asset is transferred to. * `vault_sub_id` - The sub-identifier of the asset to mint. -* `amount` - The quantity of tokens to mint. +* `amount` - The quantity of coins to mint. ### `fn burn(vault_sub_id: SubId, amount: u64)` -This function MUST burn `amount` tokens with the sub-identifier `vault_sub_id` and MUST ensure the `AssetId` of the token is the sha-256 hash of `(ContractId, SubId)` for the implementing contract. -This function MUST ensure at least `amount` tokens have been transferred to the implementing contract. -This function MUST update the total supply defined in the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +This function MUST burn `amount` coins with the sub-identifier `vault_sub_id` and MUST ensure the `AssetId` of the asset is the sha-256 hash of `(ContractId, SubId)` for the implementing contract. +This function MUST ensure at least `amount` coins have been transferred to the implementing contract. +This function MUST update the total supply defined in the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. This function MAY contain arbitrary conditions for burning, and revert if those conditions are not met. ##### Arguments * `vault_sub_id` - The sub-identifier of the asset to burn. -* `amount` - The quantity of tokens to burn. +* `amount` - The quantity of coins to burn. # Rationale -This standard has been added to enable compatibility between applications and allow minting and burning tokens per use case. This standard has been separated from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard to allow for the minting and burning for all fungible tokens, irrelevant of whether they are [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) or not. +This standard has been added to enable compatibility between applications and allow minting and burning native assets per use case. This standard has been separated from the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard to allow for the minting and burning for all fungible assets, irrelevant of whether they are [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) or not. # Backwards Compatibility -This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) ensuring its compatibility with the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) ensuring its compatibility with the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Security Considerations This standard may introduce security considerations if no checks are implemented to ensure the calling of the `mint()` function is deemed valid or permitted. Checks are highly encouraged. -The burn function may also introduce a security consideration if the total supply within the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard is not modified. +The burn function may also introduce a security consideration if the total supply within the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard is not modified. # Example ABI ```rust -abi MySRC3Token { +abi MySRC3Asset { fn mint(recipient: Identity, vault_sub_id: SubId, amount: u64); fn burn(vault_sub_id: SubId, amount: u64); } diff --git a/standards/src3-mint-burn/src/src3.sw b/standards/src3-mint-burn/src/src3.sw index b9eed4a..dbcfb59 100644 --- a/standards/src3-mint-burn/src/src3.sw +++ b/standards/src3-mint-burn/src/src3.sw @@ -1,13 +1,13 @@ library; abi SRC3 { - /// Mints new tokens using the `vault_sub_id` sub-identifier. + /// Mints new assets using the `vault_sub_id` sub-identifier. /// /// # Arguments /// - /// * `recipient`: [Identity] - The user to which the newly minted tokens are transferred to. - /// * `vault_sub_id`: [SubId] - The sub-identifier of the newly minted token. - /// * `amount`: [u64] - The quantity of tokens to mint. + /// * `recipient`: [Identity] - The user to which the newly minted asset is transferred to. + /// * `vault_sub_id`: [SubId] - The sub-identifier of the newly minted asset. + /// * `amount`: [u64] - The quantity of coins to mint. /// /// # Examples /// @@ -22,7 +22,7 @@ abi SRC3 { #[storage(read, write)] fn mint(recipient: Identity, vault_sub_id: SubId, amount: u64); - /// Burns tokens sent with the given `vault_sub_id`. + /// Burns assets sent with the given `vault_sub_id`. /// /// # Additional Information /// @@ -31,8 +31,8 @@ abi SRC3 { /// /// # Arguments /// - /// * `vault_sub_id`: [SubId] - The sub-identifier of the token to burn. - /// * `amount`: [u64] - The quantity of tokens to burn. + /// * `vault_sub_id`: [SubId] - The sub-identifier of the asset to burn. + /// * `amount`: [u64] - The quantity of coins to burn. /// /// # Examples /// diff --git a/standards/src6-vault/README.md b/standards/src6-vault/README.md index 4cecf9e..ca61f20 100644 --- a/standards/src6-vault/README.md +++ b/standards/src6-vault/README.md @@ -7,15 +7,15 @@ # Abstract -The following standard allows for the implementation of a standard API for token vaults such as yield-bearing token vaults or asset wrappers. This standard is an optional add-on to the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +The following standard allows for the implementation of a standard API for asset vaults such as yield-bearing asset vaults or asset wrappers. This standard is an optional add-on to the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Motivation -Token vaults allow users to own shares of variable amounts of assets, such as lending protocols which may have growing assets due to profits from interest. This pattern is highly useful and would greatly benefit from standardization. +Asset vaults allow users to own shares of variable amounts of assets, such as lending protocols which may have growing assets due to profits from interest. This pattern is highly useful and would greatly benefit from standardization. # Prior Art -Token vaults have been thoroughly explored on Ethereum and with [EIP 4626](https://eips.ethereum.org/EIPS/eip-4626) they have their own standard for it. However as Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) are fundamentally different from Ethereum's ERC-20 tokens, the implementation will differ, but the interface may be used as a reference. +Asset vaults have been thoroughly explored on Ethereum and with [EIP 4626](https://eips.ethereum.org/EIPS/eip-4626) they have their own standard for it. However as Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) are fundamentally different from Ethereum's ERC-20 tokens, the implementation will differ, but the interface may be used as a reference. # Specification @@ -131,7 +131,7 @@ The `vault_sub_id` field MUST represent the SubId of the vault from which was wi #### - `withdrawn_amount`: u64 -The `withdrawn_amount` field MUST represent the u64 amount of tokens withdrawn. +The `withdrawn_amount` field MUST represent the u64 amount of coins withdrawn. #### - `burned_shares`: u64 @@ -139,15 +139,15 @@ The `burned_shares` field MUST represent the u64 amount of shares burned. # Rationale -The ABI discussed covers the known use cases of token vaults while allowing safe implementations. +The ABI discussed covers the known use cases of asset vaults while allowing safe implementations. # Backwards Compatibility -This standard is fully compatible with the [SRC-20 standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20). +This standard is fully compatible with the [SRC-20 standard](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset). # Security Considerations -Incorrect implementation of token vaults could allow attackers to steal underlying assets. It is recommended to properly audit any code using this standard to ensure exploits are not possible. +Incorrect implementation of asset vaults could allow attackers to steal underlying assets. It is recommended to properly audit any code using this standard to ensure exploits are not possible. # Example ABI @@ -174,14 +174,14 @@ abi SRC6 { # Example Implementation -## [Multi Token Vault](../../examples/src6-vault/multi_token_vault/) +## [Multi Asset Vault](../../examples/src6-vault/multi_asset_vault/) A basic implementation of the vault standard that supports any number of sub vaults being created for every AssetId. -## [Single Token Vault](../../examples/src6-vault/single_token_vault/) +## [Single Asset Vault](../../examples/src6-vault/single_asset_vault/) A basic implementation of the vault standard demonstrating how to restrict deposits and withdrawals to a single AssetId. -## [Single Token Single Sub Vault](../../examples/src6-vault/single_token_single_sub_vault/) +## [Single Asset Single Sub Vault](../../examples/src6-vault/single_asset_single_sub_vault/) A basic implementation of the vault standard demonstrating how to restrict deposits and withdrawals to a single AssetId, and to a single Sub vault. \ No newline at end of file diff --git a/standards/src7-metadata/README.md b/standards/src7-metadata/README.md index 17837c4..c1adcfa 100644 --- a/standards/src7-metadata/README.md +++ b/standards/src7-metadata/README.md @@ -7,7 +7,7 @@ # Abstract -The following standard attempts to define the retrieval of on-chain arbitrary metadata for any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-7 standard MUST implement the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. +The following standard attempts to define the retrieval of on-chain arbitrary metadata for any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-7 standard MUST implement the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. # Motivation @@ -17,7 +17,7 @@ The SRC-7 standard seeks to enable data-rich assets on the Fuel Network while ma The use of generic metadata was originally found in the Sway-Lib's [NFT Library](https://github.com/FuelLabs/sway-libs/tree/v0.12.0/libs/nft) which did not use Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). This library has since been deprecated. -A previous definition for a metadata standard was written in the original edit of the now defunct [SRC-721](https://github.com/FuelLabs/sway-standards/issues/2). This has since been replaced with the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard as `SubId` was introduced to enable multiple assets to be minted from a single contract. +A previous definition for a metadata standard was written in the original edit of the now defunct [SRC-721](https://github.com/FuelLabs/sway-standards/issues/2). This has since been replaced with the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard as `SubId` was introduced to enable multiple assets to be minted from a single contract. The standard takes inspiration from [ENS's public resolver](https://docs.ens.domains/contract-api-reference/publicresolver) with the use of a `String` as the key. This should enable human-readable keys to help minimize errors and enable the standardization of certain keys, such as "image" as opposed to an `enum` or `u64` representation of keys. @@ -57,7 +57,7 @@ The SRC-7 standard should allow for data-rich assets to interact with one anothe # Backwards Compatibility -This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) and the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard. It also maintains compatibility with existing standards in other ecosystems. +This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) and the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard. It also maintains compatibility with existing standards in other ecosystems. # Security Considerations diff --git a/standards/src8-bridged-asset/README.md b/standards/src8-bridged-asset/README.md index c5e81ab..7a077f2 100644 --- a/standards/src8-bridged-asset/README.md +++ b/standards/src8-bridged-asset/README.md @@ -8,7 +8,7 @@ # Abstract -The following standard attempts to define the retrieval of relevant on-chain metadata for any bridged [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-8 standard MUST implement the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) and [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standards. +The following standard attempts to define the retrieval of relevant on-chain metadata for any bridged [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-8 standard MUST implement the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) and [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standards. # Motivation @@ -16,13 +16,13 @@ The SRC-8 standard seeks to enable relevant data for bridged assets on the Fuel # Prior Art -The use of generic metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) is defined in the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. This standard integrates into the existing [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. +The use of generic metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) is defined in the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. This standard integrates into the existing [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. # Specification -## Token Creation +## Asset Creation -The `SubId` of the token MUST be the digest of the `sha256(origin_chain_id, origin_asset_address, origin_asset_id)` hash where: +The `SubId` of the asset MUST be the digest of the `sha256(origin_chain_id, origin_asset_address, origin_asset_id)` hash where: - `origin_chain_id` is a `String` of the chain ID where the asset was originally minted. - `origin_asset_address` is a `b256` of the asset's address on the chain where the asset was originally minted. @@ -56,7 +56,7 @@ The SRC-8 standard should allow for data on any bridged assets on the Fuel Netwo # Backwards Compatibility -This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets), the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard, and the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. +This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets), the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard, and the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. The standard is also compatible with both tokens and NFTs native to other ecosystems by introducing a token ID element of the original chain. diff --git a/standards/src9-metadata-keys/README.md b/standards/src9-metadata-keys/README.md index ef19a6f..ab9cf99 100644 --- a/standards/src9-metadata-keys/README.md +++ b/standards/src9-metadata-keys/README.md @@ -7,7 +7,7 @@ # Abstract -The following standard attempts to define the keys of relevant on-chain metadata for any [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-9 standard MUST implement the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) and [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standards. This is a living standard where revisions may be made as the ecosystem evolves. +The following standard attempts to define the keys of relevant on-chain metadata for any [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-9 standard MUST implement the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) and [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standards. This is a living standard where revisions may be made as the ecosystem evolves. # Motivation @@ -15,7 +15,7 @@ The SRC-9 standard seeks to enable relevant data for assets on the Fuel Network. # Prior Art -The use of generic metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) is defined in the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. This standard integrates into the existing [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. +The use of generic metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) is defined in the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. This standard integrates into the existing [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. # Specification @@ -191,7 +191,7 @@ The key `res:block` SHALL return a `Int` variant of a block number. ## Images -The `image` prefix SHALL be used for any image files associated with a singular token. +The `image` prefix SHALL be used for any image files associated with a singular asset. Any image metadata keys SHALL follow the following syntax `image:type` where: - The `image` keyword must be prepended to denote this is an image @@ -223,7 +223,7 @@ The key `image:heif` SHALL return a `String` variant of a URI for a HEIF image. ## Video -The `video` prefix SHALL be used for any video files associated with a singular token. +The `video` prefix SHALL be used for any video files associated with a singular asset. Any video metadata keys SHALL follow the following syntax `video:type` where: - The `video` keyword must be prepended to denote this is a video @@ -251,7 +251,7 @@ The key `video:ogg` SHALL return a `String` variant of a URI for an OGG video. ## Audio -The `audio` prefix SHALL be used for any audio files associated with a singular token. +The `audio` prefix SHALL be used for any audio files associated with a singular asset. Any audio metadata keys SHALL follow the following syntax `audio:type` where: - The `audio` keyword must be prepended to denote this is audio metadata @@ -271,7 +271,7 @@ The key `audio:oga` SHALL return a `String` variant of a URI for an OGA file. ## Media -The `media` prefix SHALL be used for any media associated with a particular singular token. +The `media` prefix SHALL be used for any media associated with a particular singular asset. Any media metadata keys SHALL follow the following syntax `media:type` where: - The `media` keyword must be prepended to denote this is a video @@ -331,7 +331,7 @@ The key `logo:large_dark` SHALL return a `String` variant of a URI for a 1024x10 ## Attributes -The `attr` prefix SHALL be used for any attributes associated with a singular token. +The `attr` prefix SHALL be used for any attributes associated with a singular asset. Any attribute metadata keys SHALL follow the following syntax `attr:type` where: - The `attr` keyword must be prepended to denote this is an attribute @@ -346,7 +346,7 @@ The SRC-9 standard should allow for standardized keys for metadata on the Fuel N # Backwards Compatibility -This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets), the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_20) standard, and the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src_7) standard. +This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets), the [SRC-20](https://github.com/FuelLabs/sway-standards/tree/master/standards/src20-native-asset) standard, and the [SRC-7](https://github.com/FuelLabs/sway-standards/tree/master/standards/src7-metadata) standard. # Security Considerations