git.delta.rocks / unique-network / refs/commits / 2e3c4de7682f

difftreelog

Merge pull request #647 from UniqueNetwork/feature/supports-interface-for-erc721-metadata

Yaroslav Bolyukin2022-10-18parents: #764e4a6 #7e2fc0e.patch.diff
in: master

57 files changed

modified.maintain/scripts/generate_sol.shdiffbeforeafterboth
--- a/.maintain/scripts/generate_sol.sh
+++ b/.maintain/scripts/generate_sol.sh
@@ -11,4 +11,6 @@
 formatted=$(mktemp)
 prettier --config $PRETTIER_CONFIG $raw > $formatted
 
+sed -i -E -e "s/.+\/\/ FORMATTING: FORCE NEWLINE//g" $formatted
+
 mv $formatted $OUTPUT
modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -291,22 +291,40 @@
 
 struct MethodInfo {
 	rename_selector: Option<String>,
+	hide: bool,
 }
 impl Parse for MethodInfo {
 	fn parse(input: ParseStream) -> syn::Result<Self> {
 		let mut rename_selector = None;
-		let lookahead = input.lookahead1();
-		if lookahead.peek(kw::rename_selector) {
-			let k = input.parse::<kw::rename_selector>()?;
-			input.parse::<Token![=]>()?;
-			if rename_selector
-				.replace(input.parse::<LitStr>()?.value())
-				.is_some()
-			{
-				return Err(syn::Error::new(k.span(), "rename_selector is already set"));
+		let mut hide = false;
+		while !input.is_empty() {
+			let lookahead = input.lookahead1();
+			if lookahead.peek(kw::rename_selector) {
+				let k = input.parse::<kw::rename_selector>()?;
+				input.parse::<Token![=]>()?;
+				if rename_selector
+					.replace(input.parse::<LitStr>()?.value())
+					.is_some()
+				{
+					return Err(syn::Error::new(k.span(), "rename_selector is already set"));
+				}
+			} else if lookahead.peek(kw::hide) {
+				input.parse::<kw::hide>()?;
+				hide = true;
+			} else {
+				return Err(lookahead.error());
+			}
+
+			if input.peek(Token![,]) {
+				input.parse::<Token![,]>()?;
+			} else if !input.is_empty() {
+				return Err(syn::Error::new(input.span(), "expected end"));
 			}
 		}
-		Ok(Self { rename_selector })
+		Ok(Self {
+			rename_selector,
+			hide,
+		})
 	}
 }
 
@@ -548,6 +566,7 @@
 	syn::custom_keyword!(expect_selector);
 
 	syn::custom_keyword!(rename_selector);
+	syn::custom_keyword!(hide);
 }
 
 /// Rust methods are parsed into this structure when Solidity code is generated
@@ -558,6 +577,7 @@
 	screaming_name: Ident,
 	selector_str: String,
 	selector: u32,
+	hide: bool,
 	args: Vec<MethodArg>,
 	has_normal_args: bool,
 	has_value_args: bool,
@@ -570,6 +590,7 @@
 	fn try_from(value: &ImplItemMethod) -> syn::Result<Self> {
 		let mut info = MethodInfo {
 			rename_selector: None,
+			hide: false,
 		};
 		let mut docs = Vec::new();
 		let mut weight = None;
@@ -667,6 +688,7 @@
 			screaming_name: snake_ident_to_screaming(ident),
 			selector_str,
 			selector,
+			hide: info.hide,
 			args,
 			has_normal_args,
 			has_value_args,
@@ -826,12 +848,14 @@
 		let docs = &self.docs;
 		let selector_str = &self.selector_str;
 		let selector = self.selector;
+		let hide = self.hide;
 		let is_payable = self.has_value_args;
 		quote! {
 			SolidityFunction {
 				docs: &[#(#docs),*],
 				selector_str: #selector_str,
 				selector: #selector,
+				hide: #hide,
 				name: #camel_name,
 				mutability: #mutability,
 				is_payable: #is_payable,
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -225,7 +225,7 @@
 
 pub trait SolidityArguments {
 	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
-	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result;
+	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result;
 	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
 	fn is_empty(&self) -> bool {
 		self.len() == 0
@@ -248,7 +248,7 @@
 			Ok(())
 		}
 	}
-	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {
+	fn solidity_get(&self, _prefix: &str, _writer: &mut impl fmt::Write) -> fmt::Result {
 		Ok(())
 	}
 	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
@@ -283,8 +283,8 @@
 			Ok(())
 		}
 	}
-	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {
-		writeln!(writer, "\t\t{};", self.0)
+	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result {
+		writeln!(writer, "\t{prefix}\t{};", self.0)
 	}
 	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
 		T::solidity_default(writer, tc)
@@ -318,8 +318,8 @@
 			Ok(())
 		}
 	}
-	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {
-		writeln!(writer, "\t\t{};", self.1)
+	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result {
+		writeln!(writer, "\t{prefix}\t{};", self.1)
 	}
 	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
 		T::solidity_default(writer, tc)
@@ -337,7 +337,7 @@
 	fn solidity_name(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {
 		Ok(())
 	}
-	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {
+	fn solidity_get(&self, _prefix: &str, _writer: &mut impl fmt::Write) -> fmt::Result {
 		Ok(())
 	}
 	fn solidity_default(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {
@@ -365,9 +365,9 @@
         )* );
 		Ok(())
 	}
-	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {
+	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result {
 		for_tuples!( #(
-            Tuple.solidity_get(writer)?;
+            Tuple.solidity_get(prefix, writer)?;
         )* );
 		Ok(())
 	}
@@ -418,6 +418,7 @@
 	pub docs: &'static [&'static str],
 	pub selector_str: &'static str,
 	pub selector: u32,
+	pub hide: bool,
 	pub name: &'static str,
 	pub args: A,
 	pub result: R,
@@ -431,16 +432,21 @@
 		writer: &mut impl fmt::Write,
 		tc: &TypeCollector,
 	) -> fmt::Result {
+		let hide_comment = self.hide.then(|| "// ").unwrap_or("");
 		for doc in self.docs {
-			writeln!(writer, "\t///{}", doc)?;
+			writeln!(writer, "\t{hide_comment}///{}", doc)?;
 		}
 		writeln!(
 			writer,
-			"\t/// @dev EVM selector for this function is: 0x{:0>8x},",
+			"\t{hide_comment}/// @dev EVM selector for this function is: 0x{:0>8x},",
 			self.selector
 		)?;
-		writeln!(writer, "\t///  or in textual repr: {}", self.selector_str)?;
-		write!(writer, "\tfunction {}(", self.name)?;
+		writeln!(
+			writer,
+			"\t{hide_comment}///  or in textual repr: {}",
+			self.selector_str
+		)?;
+		write!(writer, "\t{hide_comment}function {}(", self.name)?;
 		self.args.solidity_name(writer, tc)?;
 		write!(writer, ")")?;
 		if is_impl {
@@ -463,22 +469,25 @@
 		}
 		if is_impl {
 			writeln!(writer, " {{")?;
-			writeln!(writer, "\t\trequire(false, stub_error);")?;
-			self.args.solidity_get(writer)?;
+			writeln!(writer, "\t{hide_comment}\trequire(false, stub_error);")?;
+			self.args.solidity_get(hide_comment, writer)?;
 			match &self.mutability {
 				SolidityMutability::Pure => {}
-				SolidityMutability::View => writeln!(writer, "\t\tdummy;")?,
-				SolidityMutability::Mutable => writeln!(writer, "\t\tdummy = 0;")?,
+				SolidityMutability::View => writeln!(writer, "\t{hide_comment}\tdummy;")?,
+				SolidityMutability::Mutable => writeln!(writer, "\t{hide_comment}\tdummy = 0;")?,
 			}
 			if !self.result.is_empty() {
-				write!(writer, "\t\treturn ")?;
+				write!(writer, "\t{hide_comment}\treturn ")?;
 				self.result.solidity_default(writer, tc)?;
 				writeln!(writer, ";")?;
 			}
-			writeln!(writer, "\t}}")?;
+			writeln!(writer, "\t{hide_comment}}}")?;
 		} else {
 			writeln!(writer, ";")?;
 		}
+		if self.hide {
+			writeln!(writer, "// FORMATTING: FORCE NEWLINE")?;
+		}
 		Ok(())
 	}
 }
modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -9,7 +9,7 @@
 	traits::Get,
 };
 use sp_runtime::DispatchError;
-use up_data_structs::{CollectionId, CreateCollectionData};
+use up_data_structs::{CollectionId, CreateCollectionData, CollectionFlags};
 
 use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle};
 
@@ -80,6 +80,7 @@
 		sender: T::CrossAccountId,
 		payer: T::CrossAccountId,
 		data: CreateCollectionData<T::AccountId>,
+		flags: CollectionFlags,
 	) -> Result<CollectionId, DispatchError>;
 
 	/// Delete the collection.
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -592,6 +592,7 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
+	#[solidity(rename_selector = "changeCollectionOwner")]
 	fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {
 		self.consume_store_writes(1)?;
 
@@ -659,11 +660,6 @@
 	/// Keys.
 	pub mod key {
 		use super::*;
-
-		/// Key "schemaName".
-		pub fn schema_name() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)
-		}
 
 		/// Key "baseURI".
 		pub fn base_uri() -> up_data_structs::PropertyKey {
@@ -672,30 +668,17 @@
 
 		/// Key "url".
 		pub fn url() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)
+			property_key_from_bytes(b"URI").expect(EXPECT_CONVERT_ERROR)
 		}
 
 		/// Key "suffix".
 		pub fn suffix() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)
+			property_key_from_bytes(b"URISuffix").expect(EXPECT_CONVERT_ERROR)
 		}
 
 		/// Key "parentNft".
 		pub fn parent_nft() -> up_data_structs::PropertyKey {
 			property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)
-		}
-	}
-
-	/// Values.
-	pub mod value {
-		use super::*;
-
-		/// Value "ERC721Metadata".
-		pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";
-
-		/// Value for [`ERC721_METADATA`].
-		pub fn erc721() -> up_data_structs::PropertyValue {
-			property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)
 		}
 	}
 
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -71,6 +71,7 @@
 	Collection,
 	RpcCollection,
 	CollectionFlags,
+	RpcCollectionFlags,
 	CollectionId,
 	CreateItemData,
 	MAX_TOKEN_PREFIX_LENGTH,
@@ -824,7 +825,11 @@
 			token_property_permissions,
 			properties,
 			read_only: flags.external,
-			foreign: flags.foreign,
+
+			flags: RpcCollectionFlags {
+				foreign: flags.foreign,
+				erc721metadata: flags.erc721metadata,
+			},
 		})
 	}
 }
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -212,8 +212,9 @@
 		owner: T::CrossAccountId,
 		payer: T::CrossAccountId,
 		data: CreateCollectionData<T::AccountId>,
+		flags: CollectionFlags,
 	) -> Result<CollectionId, DispatchError> {
-		<PalletCommon<T>>::init_collection(owner, payer, data, CollectionFlags::default())
+		<PalletCommon<T>>::init_collection(owner, payer, data, flags)
 	}
 
 	/// Initializes the collection with ForeignCollection flag. Returns [CollectionId] on success, [DispatchError] otherwise.
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -296,9 +296,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) public {
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) public {
 		require(false, stub_error);
 		newOwner;
 		dummy = 0;
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -55,7 +55,7 @@
 		owner,
 		CollectionMode::NFT,
 		|owner: T::CrossAccountId, data| {
-			<Pallet<T>>::init_collection(owner.clone(), owner, data, true)
+			<Pallet<T>>::init_collection(owner.clone(), owner, data, Default::default())
 		},
 		NonfungibleHandle::cast,
 	)
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -33,16 +33,12 @@
 use pallet_evm_coder_substrate::dispatch_to_evm;
 use sp_std::vec::Vec;
 use pallet_common::{
-	erc::{
-		CommonEvmHandler, PrecompileResult, CollectionCall,
-		static_property::{key, value as property_value},
-	},
+	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
 	CollectionHandle, CollectionPropertyPermissions,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
 use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use alloc::string::ToString;
 
 use crate::{
 	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
@@ -194,7 +190,7 @@
 }
 
 #[derive(ToLog)]
-pub enum ERC721MintableEvents {
+pub enum ERC721UniqueMintableEvents {
 	#[allow(dead_code)]
 	MintingFinished {},
 }
@@ -204,15 +200,17 @@
 #[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
 impl<T: Config> NonfungibleHandle<T> {
 	/// @notice A descriptive name for a collection of NFTs in this contract
-	fn name(&self) -> Result<string> {
-		Ok(decode_utf16(self.name.iter().copied())
-			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
-			.collect::<string>())
+	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	#[solidity(hide, rename_selector = "name")]
+	fn name_proxy(&self) -> Result<string> {
+		self.name()
 	}
 
 	/// @notice An abbreviated name for NFTs in this contract
-	fn symbol(&self) -> Result<string> {
-		Ok(string::from_utf8_lossy(&self.token_prefix).into())
+	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	#[solidity(hide, rename_selector = "symbol")]
+	fn symbol_proxy(&self) -> Result<string> {
+		self.symbol()
 	}
 
 	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
@@ -228,35 +226,38 @@
 	fn token_uri(&self, token_id: uint256) -> Result<string> {
 		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
 
-		if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {
-			if !url.is_empty() {
-				return Ok(url);
+		match get_token_property(self, token_id_u32, &key::url()).as_deref() {
+			Err(_) | Ok("") => (),
+			Ok(url) => {
+				return Ok(url.into());
 			}
-		} else if !is_erc721_metadata_compatible::<T>(self.id) {
-			return Err("tokenURI not set".into());
-		}
+		};
 
-		if let Some(base_uri) =
+		let base_uri =
 			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())
-		{
-			if !base_uri.is_empty() {
-				let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {
+				.map(BoundedVec::into_inner)
+				.map(string::from_utf8)
+				.transpose()
+				.map_err(|e| {
 					Error::Revert(alloc::format!(
 						"Can not convert value \"baseURI\" to string with error \"{}\"",
 						e
 					))
 				})?;
-				if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {
-					if !suffix.is_empty() {
-						return Ok(base_uri + suffix.as_str());
-					}
-				}
 
-				return Ok(base_uri + token_id.to_string().as_str());
+		let base_uri = match base_uri.as_deref() {
+			None | Some("") => {
+				return Ok("".into());
 			}
-		}
+			Some(base_uri) => base_uri.into(),
+		};
 
-		Ok("".into())
+		Ok(
+			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {
+				Err(_) | Ok("") => base_uri,
+				Ok(suffix) => base_uri + suffix,
+			},
+		)
 	}
 }
 
@@ -427,19 +428,33 @@
 }
 
 /// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
 impl<T: Config> NonfungibleHandle<T> {
 	fn minting_finished(&self) -> Result<bool> {
 		Ok(false)
 	}
 
 	/// @notice Function to mint token.
+	/// @param to The new owner
+	/// @return uint256 The id of the newly minted token
+	#[weight(<SelfWeightOf<T>>::create_item())]
+	fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {
+		let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+			.checked_add(1)
+			.ok_or("item id overflow")?
+			.into();
+		self.mint_check_id(caller, to, token_id)?;
+		Ok(token_id)
+	}
+
+	/// @notice Function to mint token.
 	/// @dev `tokenId` should be obtained with `nextTokenId` method,
 	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
 	/// @param tokenId ID of the minted NFT
+	#[solidity(hide, rename_selector = "mint")]
 	#[weight(<SelfWeightOf<T>>::create_item())]
-	fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
+	fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
 		let token_id: u32 = token_id.try_into()?;
@@ -470,14 +485,34 @@
 	}
 
 	/// @notice Function to mint token with the given tokenUri.
+	/// @param to The new owner
+	/// @param tokenUri Token URI that would be stored in the NFT properties
+	/// @return uint256 The id of the newly minted token
+	#[solidity(rename_selector = "mintWithTokenURI")]
+	#[weight(<SelfWeightOf<T>>::create_item())]
+	fn mint_with_token_uri(
+		&mut self,
+		caller: caller,
+		to: address,
+		token_uri: string,
+	) -> Result<uint256> {
+		let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+			.checked_add(1)
+			.ok_or("item id overflow")?
+			.into();
+		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;
+		Ok(token_id)
+	}
+
+	/// @notice Function to mint token with the given tokenUri.
 	/// @dev `tokenId` should be obtained with `nextTokenId` method,
 	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
 	/// @param tokenId ID of the minted NFT
 	/// @param tokenUri Token URI that would be stored in the NFT properties
-	#[solidity(rename_selector = "mintWithTokenURI")]
+	#[solidity(hide, rename_selector = "mintWithTokenURI")]
 	#[weight(<SelfWeightOf<T>>::create_item())]
-	fn mint_with_token_uri(
+	fn mint_with_token_uri_check_id(
 		&mut self,
 		caller: caller,
 		to: address,
@@ -550,17 +585,6 @@
 	Err("Property tokenURI not found".into())
 }
 
-fn is_erc721_metadata_compatible<T: Config>(collection_id: CollectionId) -> bool {
-	if let Some(shema_name) =
-		pallet_common::Pallet::<T>::get_collection_property(collection_id, &key::schema_name())
-	{
-		let shema_name = shema_name.into_inner();
-		shema_name == property_value::ERC721_METADATA
-	} else {
-		false
-	}
-}
-
 fn get_token_permission<T: Config>(
 	collection_id: CollectionId,
 	key: &PropertyKey,
@@ -575,21 +599,23 @@
 			Error::Revert(alloc::format!("No permission for key {}", key))
 		})?;
 	Ok(a)
-}
-
-fn has_token_permission<T: Config>(collection_id: CollectionId, key: &PropertyKey) -> bool {
-	if let Ok(token_property_permissions) =
-		CollectionPropertyPermissions::<T>::try_get(collection_id)
-	{
-		return token_property_permissions.contains_key(key);
-	}
-
-	false
 }
 
 /// @title Unique extensions for ERC721.
 #[solidity_interface(name = ERC721UniqueExtensions)]
 impl<T: Config> NonfungibleHandle<T> {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	fn name(&self) -> Result<string> {
+		Ok(decode_utf16(self.name.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
+	/// @notice An abbreviated name for NFTs in this contract
+	fn symbol(&self) -> Result<string> {
+		Ok(string::from_utf8_lossy(&self.token_prefix).into())
+	}
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -642,6 +668,7 @@
 	///  should be obtained with `nextTokenId` method
 	/// @param to The new owner
 	/// @param tokenIds IDs of the minted NFTs
+	// #[solidity(hide)]
 	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]
 	fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -678,7 +705,7 @@
 	///  numbers and first number should be obtained with `nextTokenId` method
 	/// @param to The new owner
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
-	#[solidity(rename_selector = "mintBulkWithTokenURI")]
+	#[solidity(/*hide,*/ rename_selector = "mintBulkWithTokenURI")]
 	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
 	fn mint_bulk_with_token_uri(
 		&mut self,
@@ -731,11 +758,11 @@
 	name = UniqueNFT,
 	is(
 		ERC721,
-		ERC721Metadata,
 		ERC721Enumerable,
 		ERC721UniqueExtensions,
-		ERC721Mintable,
+		ERC721UniqueMintable,
 		ERC721Burnable,
+		ERC721Metadata(if(this.flags.erc721metadata)),
 		Collection(via(common_mut returns CollectionHandle<T>)),
 		TokenProperties,
 	)
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
before · pallets/nonfungible/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! # Nonfungible Pallet18//!19//! The Nonfungible pallet provides functionality for handling nonfungible collections and tokens.20//!21//! - [`Config`]22//! - [`NonfungibleHandle`]23//! - [`Pallet`]24//! - [`CommonWeights`](common::CommonWeights)25//!26//! ## Overview27//!28//! The Nonfungible pallet provides functions for:29//!30//! - NFT collection creation and removal31//! - Minting and burning of NFT tokens32//! - Retrieving account balances33//! - Transfering NFT tokens34//! - Setting and checking allowance for NFT tokens35//! - Setting properties and permissions for NFT collections and tokens36//! - Nesting and unnesting tokens37//!38//! ### Terminology39//!40//! - **NFT token:** Non fungible token.41//!42//! - **NFT Collection:** A collection of NFT tokens. All NFT tokens are part of a collection.43//!   Each collection can define it's own properties, properties for it's tokens and set of permissions.44//!45//! - **Balance:** Number of NFT tokens owned by an account46//!47//! - **Allowance:** NFT tokens owned by one account that another account is allowed to make operations on48//!49//! - **Burning:** The process of “deleting” a token from a collection and from50//!   an account balance of the owner.51//!52//! - **Nesting:** Setting up parent-child relationship between tokens. Nested tokens are inhereting53//!   owner from their parent. There could be multiple levels of nesting. Token couldn't be nested in54//!   it's child token i.e. parent-child relationship graph shouldn't have cycles.55//!56//! - **Properties:** Key-Values pairs. Token properties are attached to a token. Collection properties are57//!   attached to a collection. Set of permissions could be defined for each property.58//!59//! ### Implementations60//!61//! The Nonfungible pallet provides implementations for the following traits. If these traits provide62//! the functionality that you need, then you can avoid coupling with the Nonfungible pallet.63//!64//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight65//! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing66//!   with collections67//!68//! ## Interface69//!70//! ### Dispatchable Functions71//!72//! - `init_collection` - Create NFT collection. NFT collection can be configured to allow or deny access for73//!   some accounts.74//! - `destroy_collection` - Destroy exising NFT collection. There should be no tokens in the collection.75//! - `burn` - Burn NFT token owned by account.76//! - `transfer` - Transfer NFT token. Transfers should be enabled for NFT collection.77//!   Nests the NFT token if it is sent to another token.78//! - `create_item` - Mint NFT token in collection. Sender should have permission to mint tokens.79//! - `set_allowance` - Set allowance for another account.80//! - `set_token_property` - Set token property value.81//! - `delete_token_property` - Remove property from the token.82//! - `set_collection_properties` - Set collection properties.83//! - `delete_collection_properties` - Remove properties from the collection.84//! - `set_property_permission` - Set collection property permission.85//! - `set_token_property_permissions` - Set token property permissions.86//!87//! ## Assumptions88//!89//! * To perform operations on tokens sender should be in collection's allow list if collection access mode is `AllowList`.9091#![cfg_attr(not(feature = "std"), no_std)]9293use erc::ERC721Events;94use evm_coder::ToLog;95use frame_support::{96	BoundedVec, ensure, fail, transactional,97	storage::with_transaction,98	pallet_prelude::DispatchResultWithPostInfo,99	pallet_prelude::Weight,100	weights::{PostDispatchInfo, Pays},101};102use up_data_structs::{103	AccessMode, CollectionId, CollectionFlags, CustomDataLimit, TokenId, CreateCollectionData,104	CreateNftExData, mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission,105	PropertyKey, PropertyValue, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty,106	TokenChild, AuxPropertyValue,107};108use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};109use pallet_common::{110	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,111	eth::collection_id_to_address,112};113use pallet_structure::{Pallet as PalletStructure, Error as StructureError};114use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};115use sp_core::H160;116use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};117use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};118use core::ops::Deref;119use codec::{Encode, Decode, MaxEncodedLen};120use scale_info::TypeInfo;121122pub use pallet::*;123use weights::WeightInfo;124#[cfg(feature = "runtime-benchmarks")]125pub mod benchmarking;126pub mod common;127pub mod erc;128pub mod weights;129130pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;131pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;132133/// Token data, stored independently from other data used to describe it134/// for the convenience of database access. Notably contains the owner account address.135#[struct_versioning::versioned(version = 2, upper)]136#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]137pub struct ItemData<CrossAccountId> {138	#[version(..2)]139	pub const_data: BoundedVec<u8, CustomDataLimit>,140141	#[version(..2)]142	pub variable_data: BoundedVec<u8, CustomDataLimit>,143144	pub owner: CrossAccountId,145}146147#[frame_support::pallet]148pub mod pallet {149	use super::*;150	use frame_support::{151		Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key, traits::StorageVersion,152	};153	use frame_system::pallet_prelude::*;154	use up_data_structs::{CollectionId, TokenId};155	use super::weights::WeightInfo;156157	#[pallet::error]158	pub enum Error<T> {159		/// Not Nonfungible item data used to mint in Nonfungible collection.160		NotNonfungibleDataUsedToMintFungibleCollectionToken,161		/// Used amount > 1 with NFT162		NonfungibleItemsHaveNoAmount,163		/// Unable to burn NFT with children164		CantBurnNftWithChildren,165	}166167	#[pallet::config]168	pub trait Config:169		frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config170	{171		type WeightInfo: WeightInfo;172	}173174	const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);175176	#[pallet::pallet]177	#[pallet::storage_version(STORAGE_VERSION)]178	#[pallet::generate_store(pub(super) trait Store)]179	pub struct Pallet<T>(_);180181	/// Total amount of minted tokens in a collection.182	#[pallet::storage]183	pub type TokensMinted<T: Config> =184		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;185186	/// Amount of burnt tokens in a collection.187	#[pallet::storage]188	pub type TokensBurnt<T: Config> =189		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;190191	/// Token data, used to partially describe a token.192	#[pallet::storage]193	pub type TokenData<T: Config> = StorageNMap<194		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),195		Value = ItemData<T::CrossAccountId>,196		QueryKind = OptionQuery,197	>;198199	/// Map of key-value pairs, describing the metadata of a token.200	#[pallet::storage]201	#[pallet::getter(fn token_properties)]202	pub type TokenProperties<T: Config> = StorageNMap<203		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),204		Value = Properties,205		QueryKind = ValueQuery,206		OnEmpty = up_data_structs::TokenProperties,207	>;208209	/// Custom data of a token that is serialized to bytes,210	/// primarily reserved for on-chain operations,211	/// normally obscured from the external users.212	///213	/// Auxiliary properties are slightly different from214	/// usual [`TokenProperties`] due to an unlimited number215	/// and separately stored and written-to key-value pairs.216	///217	/// Currently used to store RMRK data.218	#[pallet::storage]219	#[pallet::getter(fn token_aux_property)]220	pub type TokenAuxProperties<T: Config> = StorageNMap<221		Key = (222			Key<Twox64Concat, CollectionId>,223			Key<Twox64Concat, TokenId>,224			Key<Twox64Concat, PropertyScope>,225			Key<Twox64Concat, PropertyKey>,226		),227		Value = AuxPropertyValue,228		QueryKind = OptionQuery,229	>;230231	/// Used to enumerate tokens owned by account.232	#[pallet::storage]233	pub type Owned<T: Config> = StorageNMap<234		Key = (235			Key<Twox64Concat, CollectionId>,236			Key<Blake2_128Concat, T::CrossAccountId>,237			Key<Twox64Concat, TokenId>,238		),239		Value = bool,240		QueryKind = ValueQuery,241	>;242243	/// Used to enumerate token's children.244	#[pallet::storage]245	#[pallet::getter(fn token_children)]246	pub type TokenChildren<T: Config> = StorageNMap<247		Key = (248			Key<Twox64Concat, CollectionId>,249			Key<Twox64Concat, TokenId>,250			Key<Twox64Concat, (CollectionId, TokenId)>,251		),252		Value = bool,253		QueryKind = ValueQuery,254	>;255256	/// Amount of tokens owned by an account in a collection.257	#[pallet::storage]258	pub type AccountBalance<T: Config> = StorageNMap<259		Key = (260			Key<Twox64Concat, CollectionId>,261			Key<Blake2_128Concat, T::CrossAccountId>,262		),263		Value = u32,264		QueryKind = ValueQuery,265	>;266267	/// Allowance set by a token owner for another user to perform one of certain transactions on a token.268	#[pallet::storage]269	pub type Allowance<T: Config> = StorageNMap<270		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),271		Value = T::CrossAccountId,272		QueryKind = OptionQuery,273	>;274275	/// Upgrade from the old schema to properties.276	#[pallet::hooks]277	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {278		fn on_runtime_upgrade() -> Weight {279			StorageVersion::new(1).put::<Pallet<T>>();280281			Weight::zero()282		}283	}284}285286pub struct NonfungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);287impl<T: Config> NonfungibleHandle<T> {288	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {289		Self(inner)290	}291	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {292		self.0293	}294	pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {295		&mut self.0296	}297}298impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {299	fn recorder(&self) -> &SubstrateRecorder<T> {300		self.0.recorder()301	}302	fn into_recorder(self) -> SubstrateRecorder<T> {303		self.0.into_recorder()304	}305}306impl<T: Config> Deref for NonfungibleHandle<T> {307	type Target = pallet_common::CollectionHandle<T>;308309	fn deref(&self) -> &Self::Target {310		&self.0311	}312}313314impl<T: Config> Pallet<T> {315	/// Get number of NFT tokens in collection.316	pub fn total_supply(collection: &NonfungibleHandle<T>) -> u32 {317		<TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)318	}319320	/// Check that NFT token exists.321	///322	/// - `token`: Token ID.323	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {324		<TokenData<T>>::contains_key((collection.id, token))325	}326327	/// Set the token property with the scope.328	///329	/// - `property`: Contains key-value pair.330	pub fn set_scoped_token_property(331		collection_id: CollectionId,332		token_id: TokenId,333		scope: PropertyScope,334		property: Property,335	) -> DispatchResult {336		TokenProperties::<T>::try_mutate((collection_id, token_id), |properties| {337			properties.try_scoped_set(scope, property.key, property.value)338		})339		.map_err(<CommonError<T>>::from)?;340341		Ok(())342	}343344	/// Batch operation to set multiple properties with the same scope.345	pub fn set_scoped_token_properties(346		collection_id: CollectionId,347		token_id: TokenId,348		scope: PropertyScope,349		properties: impl Iterator<Item = Property>,350	) -> DispatchResult {351		TokenProperties::<T>::try_mutate((collection_id, token_id), |stored_properties| {352			stored_properties.try_scoped_set_from_iter(scope, properties)353		})354		.map_err(<CommonError<T>>::from)?;355356		Ok(())357	}358359	/// Add or edit auxiliary data for the property.360	///361	/// - `f`: function that adds or edits auxiliary data.362	pub fn try_mutate_token_aux_property<R, E>(363		collection_id: CollectionId,364		token_id: TokenId,365		scope: PropertyScope,366		key: PropertyKey,367		f: impl FnOnce(&mut Option<AuxPropertyValue>) -> Result<R, E>,368	) -> Result<R, E> {369		<TokenAuxProperties<T>>::try_mutate((collection_id, token_id, scope, key), f)370	}371372	/// Remove auxiliary data for the property.373	pub fn remove_token_aux_property(374		collection_id: CollectionId,375		token_id: TokenId,376		scope: PropertyScope,377		key: PropertyKey,378	) {379		<TokenAuxProperties<T>>::remove((collection_id, token_id, scope, key));380	}381382	/// Get all auxiliary data in a given scope.383	///384	/// Returns iterator over Property Key - Data pairs.385	pub fn iterate_token_aux_properties(386		collection_id: CollectionId,387		token_id: TokenId,388		scope: PropertyScope,389	) -> impl Iterator<Item = (PropertyKey, AuxPropertyValue)> {390		<TokenAuxProperties<T>>::iter_prefix((collection_id, token_id, scope))391	}392393	/// Get ID of the last minted token394	pub fn current_token_id(collection_id: CollectionId) -> TokenId {395		TokenId(<TokensMinted<T>>::get(collection_id))396	}397}398399// unchecked calls skips any permission checks400impl<T: Config> Pallet<T> {401	/// Create NFT collection402	///403	/// `init_collection` will take non-refundable deposit for collection creation.404	///405	/// - `data`: Contains settings for collection limits and permissions.406	pub fn init_collection(407		owner: T::CrossAccountId,408		payer: T::CrossAccountId,409		data: CreateCollectionData<T::AccountId>,410		is_external: bool,411	) -> Result<CollectionId, DispatchError> {412		<PalletCommon<T>>::init_collection(413			owner,414			payer,415			data,416			CollectionFlags {417				external: is_external,418				..Default::default()419			},420		)421	}422423	/// Destroy NFT collection424	///425	/// `destroy_collection` will throw error if collection contains any tokens.426	/// Only owner can destroy collection.427	pub fn destroy_collection(428		collection: NonfungibleHandle<T>,429		sender: &T::CrossAccountId,430	) -> DispatchResult {431		let id = collection.id;432433		if Self::collection_has_tokens(id) {434			return Err(<CommonError<T>>::CantDestroyNotEmptyCollection.into());435		}436437		// =========438439		PalletCommon::destroy_collection(collection.0, sender)?;440441		let _ = <TokenData<T>>::clear_prefix((id,), u32::MAX, None);442		let _ = <TokenChildren<T>>::clear_prefix((id,), u32::MAX, None);443		let _ = <Owned<T>>::clear_prefix((id,), u32::MAX, None);444		<TokensMinted<T>>::remove(id);445		<TokensBurnt<T>>::remove(id);446		let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);447		let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);448		Ok(())449	}450451	/// Burn NFT token452	///453	/// `burn` removes `token` from the `collection`, from it's owner and from the parent token454	/// if the token is nested.455	/// Only the owner can `burn` the token. The `token` shouldn't have any nested tokens.456	/// Also removes all corresponding properties and auxiliary properties.457	///458	/// - `token`: Token that should be burned459	/// - `collection`: Collection that contains the token460	pub fn burn(461		collection: &NonfungibleHandle<T>,462		sender: &T::CrossAccountId,463		token: TokenId,464	) -> DispatchResult {465		let token_data =466			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;467		ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);468469		if collection.permissions.access() == AccessMode::AllowList {470			collection.check_allowlist(sender)?;471		}472473		if Self::token_has_children(collection.id, token) {474			return Err(<Error<T>>::CantBurnNftWithChildren.into());475		}476477		let burnt = <TokensBurnt<T>>::get(collection.id)478			.checked_add(1)479			.ok_or(ArithmeticError::Overflow)?;480481		let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))482			.checked_sub(1)483			.ok_or(ArithmeticError::Overflow)?;484485		// =========486487		if balance == 0 {488			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));489		} else {490			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);491		}492493		<PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);494495		<Owned<T>>::remove((collection.id, &token_data.owner, token));496		<TokensBurnt<T>>::insert(collection.id, burnt);497		<TokenData<T>>::remove((collection.id, token));498		<TokenProperties<T>>::remove((collection.id, token));499		let _ = <TokenAuxProperties<T>>::clear_prefix((collection.id, token), u32::MAX, None);500		let old_spender = <Allowance<T>>::take((collection.id, token));501502		if let Some(old_spender) = old_spender {503			<PalletCommon<T>>::deposit_event(CommonEvent::Approved(504				collection.id,505				token,506				token_data.owner.clone(),507				old_spender,508				0,509			));510		}511512		<PalletEvm<T>>::deposit_log(513			ERC721Events::Transfer {514				from: *token_data.owner.as_eth(),515				to: H160::default(),516				token_id: token.into(),517			}518			.to_log(collection_id_to_address(collection.id)),519		);520		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(521			collection.id,522			token,523			token_data.owner,524			1,525		));526		Ok(())527	}528529	/// Same as [`burn`] but burns all the tokens that are nested in the token first530	///531	/// - `self_budget`: Limit for searching children in depth.532	/// - `breadth_budget`: Limit of breadth of searching children.533	///534	/// [`burn`]: struct.Pallet.html#method.burn535	#[transactional]536	pub fn burn_recursively(537		collection: &NonfungibleHandle<T>,538		sender: &T::CrossAccountId,539		token: TokenId,540		self_budget: &dyn Budget,541		breadth_budget: &dyn Budget,542	) -> DispatchResultWithPostInfo {543		ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);544545		let current_token_account =546			T::CrossTokenAddressMapping::token_to_address(collection.id, token);547548		let mut weight = Weight::zero();549550		// This method is transactional, if user in fact doesn't have permissions to remove token -551		// tokens removed here will be restored after rejected transaction552		for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {553			ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);554			let PostDispatchInfo { actual_weight, .. } =555				<PalletStructure<T>>::burn_item_recursively(556					current_token_account.clone(),557					collection,558					token,559					self_budget,560					breadth_budget,561				)?;562			if let Some(actual_weight) = actual_weight {563				weight = weight.saturating_add(actual_weight);564			}565		}566567		Self::burn(collection, sender, token)?;568		DispatchResultWithPostInfo::Ok(PostDispatchInfo {569			actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),570			pays_fee: Pays::Yes,571		})572	}573574	/// Batch operation to add, edit or remove properties for the token575	///576	/// All affected properties should have mutable permission and sender should have577	/// permission to edit those properties.578	///579	/// - `nesting_budget`: Limit for searching parents in depth to check ownership.580	/// - `is_token_create`: Indicates that method is called during token initialization.581	///   Allows to bypass ownership check.582	#[transactional]583	fn modify_token_properties(584		collection: &NonfungibleHandle<T>,585		sender: &T::CrossAccountId,586		token_id: TokenId,587		properties: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,588		is_token_create: bool,589		nesting_budget: &dyn Budget,590	) -> DispatchResult {591		let mut collection_admin_status = None;592		let mut token_owner_result = None;593594		let mut is_collection_admin =595			|| *collection_admin_status.get_or_insert_with(|| collection.is_owner_or_admin(sender));596597		let mut is_token_owner = || {598			*token_owner_result.get_or_insert_with(|| -> Result<bool, DispatchError> {599				let is_owned = <PalletStructure<T>>::check_indirectly_owned(600					sender.clone(),601					collection.id,602					token_id,603					None,604					nesting_budget,605				)?;606607				Ok(is_owned)608			})609		};610611		for (key, value) in properties {612			let permission = <PalletCommon<T>>::property_permissions(collection.id)613				.get(&key)614				.cloned()615				.unwrap_or_else(PropertyPermission::none);616617			let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))618				.get(&key)619				.is_some();620621			match permission {622				PropertyPermission { mutable: false, .. } if is_property_exists => {623					return Err(<CommonError<T>>::NoPermission.into());624				}625626				PropertyPermission {627					collection_admin,628					token_owner,629					..630				} => {631					//TODO: investigate threats during public minting.632					if is_token_create && (collection_admin || token_owner) && value.is_some() {633						// Pass634					} else if collection_admin && is_collection_admin() {635						// Pass636					} else if token_owner && is_token_owner()? {637						// Pass638					} else {639						fail!(<CommonError<T>>::NoPermission);640					}641				}642			}643644			match value {645				Some(value) => {646					<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {647						properties.try_set(key.clone(), value)648					})649					.map_err(<CommonError<T>>::from)?;650651					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(652						collection.id,653						token_id,654						key,655					));656				}657				None => {658					<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {659						properties.remove(&key)660					})661					.map_err(<CommonError<T>>::from)?;662663					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(664						collection.id,665						token_id,666						key,667					));668				}669			}670		}671672		Ok(())673	}674675	/// Batch operation to add or edit properties for the token676	///677	/// Same as [`modify_token_properties`] but doesn't allow to remove properties678	///679	/// [`modify_token_properties`]: struct.Pallet.html#method.modify_token_properties680	pub fn set_token_properties(681		collection: &NonfungibleHandle<T>,682		sender: &T::CrossAccountId,683		token_id: TokenId,684		properties: impl Iterator<Item = Property>,685		is_token_create: bool,686		nesting_budget: &dyn Budget,687	) -> DispatchResult {688		Self::modify_token_properties(689			collection,690			sender,691			token_id,692			properties.map(|p| (p.key, Some(p.value))),693			is_token_create,694			nesting_budget,695		)696	}697698	/// Add or edit single property for the token699	///700	/// Calls [`set_token_properties`] internally701	///702	/// [`set_token_properties`]: struct.Pallet.html#method.set_token_properties703	pub fn set_token_property(704		collection: &NonfungibleHandle<T>,705		sender: &T::CrossAccountId,706		token_id: TokenId,707		property: Property,708		nesting_budget: &dyn Budget,709	) -> DispatchResult {710		let is_token_create = false;711712		Self::set_token_properties(713			collection,714			sender,715			token_id,716			[property].into_iter(),717			is_token_create,718			nesting_budget,719		)720	}721722	/// Batch operation to remove properties from the token723	///724	/// Same as [`modify_token_properties`] but doesn't allow to add or edit properties725	///726	/// [`modify_token_properties`]: struct.Pallet.html#method.modify_token_properties727	pub fn delete_token_properties(728		collection: &NonfungibleHandle<T>,729		sender: &T::CrossAccountId,730		token_id: TokenId,731		property_keys: impl Iterator<Item = PropertyKey>,732		nesting_budget: &dyn Budget,733	) -> DispatchResult {734		let is_token_create = false;735736		Self::modify_token_properties(737			collection,738			sender,739			token_id,740			property_keys.into_iter().map(|key| (key, None)),741			is_token_create,742			nesting_budget,743		)744	}745746	/// Remove single property from the token747	///748	/// Calls [`delete_token_properties`] internally749	///750	/// [`delete_token_properties`]: struct.Pallet.html#method.delete_token_properties751	pub fn delete_token_property(752		collection: &NonfungibleHandle<T>,753		sender: &T::CrossAccountId,754		token_id: TokenId,755		property_key: PropertyKey,756		nesting_budget: &dyn Budget,757	) -> DispatchResult {758		Self::delete_token_properties(759			collection,760			sender,761			token_id,762			[property_key].into_iter(),763			nesting_budget,764		)765	}766767	/// Add or edit properties for the collection768	pub fn set_collection_properties(769		collection: &NonfungibleHandle<T>,770		sender: &T::CrossAccountId,771		properties: Vec<Property>,772	) -> DispatchResult {773		<PalletCommon<T>>::set_collection_properties(collection, sender, properties)774	}775776	/// Remove properties from the collection777	pub fn delete_collection_properties(778		collection: &CollectionHandle<T>,779		sender: &T::CrossAccountId,780		property_keys: Vec<PropertyKey>,781	) -> DispatchResult {782		<PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)783	}784785	/// Set property permissions for the token.786	///787	/// Sender should be the owner or admin of token's collection.788	pub fn set_token_property_permissions(789		collection: &CollectionHandle<T>,790		sender: &T::CrossAccountId,791		property_permissions: Vec<PropertyKeyPermission>,792	) -> DispatchResult {793		<PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)794	}795796	/// Set property permissions for the token with scope.797	///798	/// Sender should be the owner or admin of token's collection.799	pub fn set_scoped_token_property_permissions(800		collection: &CollectionHandle<T>,801		sender: &T::CrossAccountId,802		scope: PropertyScope,803		property_permissions: Vec<PropertyKeyPermission>,804	) -> DispatchResult {805		<PalletCommon<T>>::set_scoped_token_property_permissions(806			collection,807			sender,808			scope,809			property_permissions,810		)811	}812813	/// Set property permissions for the collection.814	///815	/// Sender should be the owner or admin of the collection.816	pub fn set_property_permission(817		collection: &CollectionHandle<T>,818		sender: &T::CrossAccountId,819		permission: PropertyKeyPermission,820	) -> DispatchResult {821		<PalletCommon<T>>::set_property_permission(collection, sender, permission)822	}823824	/// Transfer NFT token from one account to another.825	///826	/// `from` account stops being the owner and `to` account becomes the owner of the token.827	/// If `to` is token than `to` becomes owner of the token and the token become nested.828	/// Unnests token from previous parent if it was nested before.829	/// Removes allowance for the token if there was any.830	/// Throws if transfers aren't allowed for collection or if receiver reached token ownership limit.831	///832	/// - `nesting_budget`: Limit for token nesting depth833	pub fn transfer(834		collection: &NonfungibleHandle<T>,835		from: &T::CrossAccountId,836		to: &T::CrossAccountId,837		token: TokenId,838		nesting_budget: &dyn Budget,839	) -> DispatchResult {840		ensure!(841			collection.limits.transfers_enabled(),842			<CommonError<T>>::TransferNotAllowed843		);844845		let token_data =846			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;847		ensure!(&token_data.owner == from, <CommonError<T>>::NoPermission);848849		if collection.permissions.access() == AccessMode::AllowList {850			collection.check_allowlist(from)?;851			collection.check_allowlist(to)?;852		}853		<PalletCommon<T>>::ensure_correct_receiver(to)?;854855		let balance_from = <AccountBalance<T>>::get((collection.id, from))856			.checked_sub(1)857			.ok_or(<CommonError<T>>::TokenValueTooLow)?;858		let balance_to = if from != to {859			let balance_to = <AccountBalance<T>>::get((collection.id, to))860				.checked_add(1)861				.ok_or(ArithmeticError::Overflow)?;862863			ensure!(864				balance_to < collection.limits.account_token_ownership_limit(),865				<CommonError<T>>::AccountTokenLimitExceeded,866			);867868			Some(balance_to)869		} else {870			None871		};872873		<PalletStructure<T>>::nest_if_sent_to_token(874			from.clone(),875			to,876			collection.id,877			token,878			nesting_budget,879		)?;880881		// =========882883		<PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);884885		<TokenData<T>>::insert(886			(collection.id, token),887			ItemData {888				owner: to.clone(),889				..token_data890			},891		);892893		if let Some(balance_to) = balance_to {894			// from != to895			if balance_from == 0 {896				<AccountBalance<T>>::remove((collection.id, from));897			} else {898				<AccountBalance<T>>::insert((collection.id, from), balance_from);899			}900			<AccountBalance<T>>::insert((collection.id, to), balance_to);901			<Owned<T>>::remove((collection.id, from, token));902			<Owned<T>>::insert((collection.id, to, token), true);903		}904		Self::set_allowance_unchecked(collection, from, token, None, true);905906		<PalletEvm<T>>::deposit_log(907			ERC721Events::Transfer {908				from: *from.as_eth(),909				to: *to.as_eth(),910				token_id: token.into(),911			}912			.to_log(collection_id_to_address(collection.id)),913		);914		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(915			collection.id,916			token,917			from.clone(),918			to.clone(),919			1,920		));921		Ok(())922	}923924	/// Batch operation to mint multiple NFT tokens.925	///926	/// The sender should be the owner/admin of the collection or collection should be configured927	/// to allow public minting.928	/// Throws if amount of tokens reached it's limit for the collection or if caller reached929	/// token ownership limit.930	///931	/// - `data`: Contains list of token properties and users who will become the owners of the932	///   corresponging tokens.933	/// - `nesting_budget`: Limit for token nesting depth934	pub fn create_multiple_items(935		collection: &NonfungibleHandle<T>,936		sender: &T::CrossAccountId,937		data: Vec<CreateItemData<T>>,938		nesting_budget: &dyn Budget,939	) -> DispatchResult {940		if !collection.is_owner_or_admin(sender) {941			ensure!(942				collection.permissions.mint_mode(),943				<CommonError<T>>::PublicMintingNotAllowed944			);945			collection.check_allowlist(sender)?;946947			for item in data.iter() {948				collection.check_allowlist(&item.owner)?;949			}950		}951952		for data in data.iter() {953			<PalletCommon<T>>::ensure_correct_receiver(&data.owner)?;954		}955956		let first_token = <TokensMinted<T>>::get(collection.id);957		let tokens_minted = first_token958			.checked_add(data.len() as u32)959			.ok_or(ArithmeticError::Overflow)?;960		ensure!(961			tokens_minted <= collection.limits.token_limit(),962			<CommonError<T>>::CollectionTokenLimitExceeded963		);964965		let mut balances = BTreeMap::new();966		for data in &data {967			let balance = balances968				.entry(&data.owner)969				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));970			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;971972			ensure!(973				*balance <= collection.limits.account_token_ownership_limit(),974				<CommonError<T>>::AccountTokenLimitExceeded,975			);976		}977978		for (i, data) in data.iter().enumerate() {979			let token = TokenId(first_token + i as u32 + 1);980981			<PalletStructure<T>>::check_nesting(982				sender.clone(),983				&data.owner,984				collection.id,985				token,986				nesting_budget,987			)?;988		}989990		// =========991992		with_transaction(|| {993			for (i, data) in data.iter().enumerate() {994				let token = first_token + i as u32 + 1;995996				<TokenData<T>>::insert(997					(collection.id, token),998					ItemData {999						// const_data: data.const_data.clone(),1000						owner: data.owner.clone(),1001					},1002				);10031004				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(1005					&data.owner,1006					collection.id,1007					TokenId(token),1008				);10091010				if let Err(e) = Self::set_token_properties(1011					collection,1012					sender,1013					TokenId(token),1014					data.properties.clone().into_iter(),1015					true,1016					nesting_budget,1017				) {1018					return TransactionOutcome::Rollback(Err(e));1019				}1020			}1021			TransactionOutcome::Commit(Ok(()))1022		})?;10231024		<TokensMinted<T>>::insert(collection.id, tokens_minted);1025		for (account, balance) in balances {1026			<AccountBalance<T>>::insert((collection.id, account), balance);1027		}1028		for (i, data) in data.into_iter().enumerate() {1029			let token = first_token + i as u32 + 1;1030			<Owned<T>>::insert((collection.id, &data.owner, token), true);10311032			<PalletEvm<T>>::deposit_log(1033				ERC721Events::Transfer {1034					from: H160::default(),1035					to: *data.owner.as_eth(),1036					token_id: token.into(),1037				}1038				.to_log(collection_id_to_address(collection.id)),1039			);1040			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(1041				collection.id,1042				TokenId(token),1043				data.owner.clone(),1044				1,1045			));1046		}1047		Ok(())1048	}10491050	pub fn set_allowance_unchecked(1051		collection: &NonfungibleHandle<T>,1052		sender: &T::CrossAccountId,1053		token: TokenId,1054		spender: Option<&T::CrossAccountId>,1055		assume_implicit_eth: bool,1056	) {1057		if let Some(spender) = spender {1058			let old_spender = <Allowance<T>>::get((collection.id, token));1059			<Allowance<T>>::insert((collection.id, token), spender);1060			// In ERC721 there is only one possible approved user of token, so we set1061			// approved user to spender1062			<PalletEvm<T>>::deposit_log(1063				ERC721Events::Approval {1064					owner: *sender.as_eth(),1065					approved: *spender.as_eth(),1066					token_id: token.into(),1067				}1068				.to_log(collection_id_to_address(collection.id)),1069			);1070			// In Unique chain, any token can have any amount of approved users, so we need to1071			// set allowance of old owner to 0, and allowance of new owner to 11072			if old_spender.as_ref() != Some(spender) {1073				if let Some(old_owner) = old_spender {1074					<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1075						collection.id,1076						token,1077						sender.clone(),1078						old_owner,1079						0,1080					));1081				}1082				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1083					collection.id,1084					token,1085					sender.clone(),1086					spender.clone(),1087					1,1088				));1089			}1090		} else {1091			let old_spender = <Allowance<T>>::take((collection.id, token));1092			if !assume_implicit_eth {1093				// In ERC721 there is only one possible approved user of token, so we set1094				// approved user to zero address1095				<PalletEvm<T>>::deposit_log(1096					ERC721Events::Approval {1097						owner: *sender.as_eth(),1098						approved: H160::default(),1099						token_id: token.into(),1100					}1101					.to_log(collection_id_to_address(collection.id)),1102				);1103			}1104			// In Unique chain, any token can have any amount of approved users, so we need to1105			// set allowance of old owner to 01106			if let Some(old_spender) = old_spender {1107				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1108					collection.id,1109					token,1110					sender.clone(),1111					old_spender,1112					0,1113				));1114			}1115		}1116	}11171118	/// Set allowance for the spender to `transfer` or `burn` sender's token.1119	///1120	/// - `token`: Token the spender is allowed to `transfer` or `burn`.1121	pub fn set_allowance(1122		collection: &NonfungibleHandle<T>,1123		sender: &T::CrossAccountId,1124		token: TokenId,1125		spender: Option<&T::CrossAccountId>,1126	) -> DispatchResult {1127		if collection.permissions.access() == AccessMode::AllowList {1128			collection.check_allowlist(sender)?;1129			if let Some(spender) = spender {1130				collection.check_allowlist(spender)?;1131			}1132		}11331134		if let Some(spender) = spender {1135			<PalletCommon<T>>::ensure_correct_receiver(spender)?;1136		}11371138		let token_data =1139			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;1140		if &token_data.owner != sender {1141			ensure!(1142				collection.ignores_owned_amount(sender),1143				<CommonError<T>>::CantApproveMoreThanOwned1144			);1145		}11461147		// =========11481149		Self::set_allowance_unchecked(collection, sender, token, spender, false);1150		Ok(())1151	}11521153	/// Checks allowance for the spender to use the token.1154	fn check_allowed(1155		collection: &NonfungibleHandle<T>,1156		spender: &T::CrossAccountId,1157		from: &T::CrossAccountId,1158		token: TokenId,1159		nesting_budget: &dyn Budget,1160	) -> DispatchResult {1161		if spender.conv_eq(from) {1162			return Ok(());1163		}1164		if collection.permissions.access() == AccessMode::AllowList {1165			// `from`, `to` checked in [`transfer`]1166			collection.check_allowlist(spender)?;1167		}11681169		if collection.limits.owner_can_transfer() && collection.is_owner_or_admin(spender) {1170			return Ok(());1171		}11721173		if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {1174			ensure!(1175				<PalletStructure<T>>::check_indirectly_owned(1176					spender.clone(),1177					source.0,1178					source.1,1179					None,1180					nesting_budget1181				)?,1182				<CommonError<T>>::ApprovedValueTooLow,1183			);1184			return Ok(());1185		}1186		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {1187			return Ok(());1188		}1189		ensure!(1190			collection.ignores_allowance(spender),1191			<CommonError<T>>::ApprovedValueTooLow1192		);1193		Ok(())1194	}11951196	/// Transfer NFT token from one account to another.1197	///1198	/// Same as the [`transfer`] but spender doesn't needs to be the owner of the token.1199	/// The owner should set allowance for the spender to transfer token.1200	///1201	/// [`transfer`]: struct.Pallet.html#method.transfer1202	pub fn transfer_from(1203		collection: &NonfungibleHandle<T>,1204		spender: &T::CrossAccountId,1205		from: &T::CrossAccountId,1206		to: &T::CrossAccountId,1207		token: TokenId,1208		nesting_budget: &dyn Budget,1209	) -> DispatchResult {1210		Self::check_allowed(collection, spender, from, token, nesting_budget)?;12111212		// =========12131214		// Allowance is reset in [`transfer`]1215		Self::transfer(collection, from, to, token, nesting_budget)1216	}12171218	/// Burn NFT token for `from` account.1219	///1220	/// Same as the [`burn`] but spender doesn't need to be an owner of the token. The owner should1221	/// set allowance for the spender to burn token.1222	///1223	/// [`burn`]: struct.Pallet.html#method.burn1224	pub fn burn_from(1225		collection: &NonfungibleHandle<T>,1226		spender: &T::CrossAccountId,1227		from: &T::CrossAccountId,1228		token: TokenId,1229		nesting_budget: &dyn Budget,1230	) -> DispatchResult {1231		Self::check_allowed(collection, spender, from, token, nesting_budget)?;12321233		// =========12341235		Self::burn(collection, from, token)1236	}12371238	/// Check that `from` token could be nested in `under` token.1239	///1240	pub fn check_nesting(1241		handle: &NonfungibleHandle<T>,1242		sender: T::CrossAccountId,1243		from: (CollectionId, TokenId),1244		under: TokenId,1245		nesting_budget: &dyn Budget,1246	) -> DispatchResult {1247		let nesting = handle.permissions.nesting();12481249		#[cfg(not(feature = "runtime-benchmarks"))]1250		let permissive = false;1251		#[cfg(feature = "runtime-benchmarks")]1252		let permissive = nesting.permissive;12531254		if permissive {1255			// Pass1256		} else if nesting.token_owner1257			&& <PalletStructure<T>>::check_indirectly_owned(1258				sender.clone(),1259				handle.id,1260				under,1261				Some(from),1262				nesting_budget,1263			)? {1264			// Pass1265		} else if nesting.collection_admin && handle.is_owner_or_admin(&sender) {1266			// Pass1267		} else {1268			fail!(<CommonError<T>>::UserIsNotAllowedToNest);1269		}12701271		if let Some(whitelist) = &nesting.restricted {1272			ensure!(1273				whitelist.contains(&from.0),1274				<CommonError<T>>::SourceCollectionIsNotAllowedToNest1275			);1276		}1277		Ok(())1278	}12791280	fn nest(under: (CollectionId, TokenId), to_nest: (CollectionId, TokenId)) {1281		<TokenChildren<T>>::insert((under.0, under.1, (to_nest.0, to_nest.1)), true);1282	}12831284	fn unnest(under: (CollectionId, TokenId), to_unnest: (CollectionId, TokenId)) {1285		<TokenChildren<T>>::remove((under.0, under.1, to_unnest));1286	}12871288	fn collection_has_tokens(collection_id: CollectionId) -> bool {1289		<TokenData<T>>::iter_prefix((collection_id,))1290			.next()1291			.is_some()1292	}12931294	fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {1295		<TokenChildren<T>>::iter_prefix((collection_id, token_id))1296			.next()1297			.is_some()1298	}12991300	pub fn token_children_ids(collection_id: CollectionId, token_id: TokenId) -> Vec<TokenChild> {1301		<TokenChildren<T>>::iter_prefix((collection_id, token_id))1302			.map(|((child_collection_id, child_id), _)| TokenChild {1303				collection: child_collection_id,1304				token: child_id,1305			})1306			.collect()1307	}13081309	/// Mint single NFT token.1310	///1311	/// Delegated to [`create_multiple_items`]1312	///1313	/// [`create_multiple_items`]: struct.Pallet.html#method.create_multiple_items1314	pub fn create_item(1315		collection: &NonfungibleHandle<T>,1316		sender: &T::CrossAccountId,1317		data: CreateItemData<T>,1318		nesting_budget: &dyn Budget,1319	) -> DispatchResult {1320		Self::create_multiple_items(collection, sender, vec![data], nesting_budget)1321	}1322}
after · pallets/nonfungible/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! # Nonfungible Pallet18//!19//! The Nonfungible pallet provides functionality for handling nonfungible collections and tokens.20//!21//! - [`Config`]22//! - [`NonfungibleHandle`]23//! - [`Pallet`]24//! - [`CommonWeights`](common::CommonWeights)25//!26//! ## Overview27//!28//! The Nonfungible pallet provides functions for:29//!30//! - NFT collection creation and removal31//! - Minting and burning of NFT tokens32//! - Retrieving account balances33//! - Transfering NFT tokens34//! - Setting and checking allowance for NFT tokens35//! - Setting properties and permissions for NFT collections and tokens36//! - Nesting and unnesting tokens37//!38//! ### Terminology39//!40//! - **NFT token:** Non fungible token.41//!42//! - **NFT Collection:** A collection of NFT tokens. All NFT tokens are part of a collection.43//!   Each collection can define it's own properties, properties for it's tokens and set of permissions.44//!45//! - **Balance:** Number of NFT tokens owned by an account46//!47//! - **Allowance:** NFT tokens owned by one account that another account is allowed to make operations on48//!49//! - **Burning:** The process of “deleting” a token from a collection and from50//!   an account balance of the owner.51//!52//! - **Nesting:** Setting up parent-child relationship between tokens. Nested tokens are inhereting53//!   owner from their parent. There could be multiple levels of nesting. Token couldn't be nested in54//!   it's child token i.e. parent-child relationship graph shouldn't have cycles.55//!56//! - **Properties:** Key-Values pairs. Token properties are attached to a token. Collection properties are57//!   attached to a collection. Set of permissions could be defined for each property.58//!59//! ### Implementations60//!61//! The Nonfungible pallet provides implementations for the following traits. If these traits provide62//! the functionality that you need, then you can avoid coupling with the Nonfungible pallet.63//!64//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight65//! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing66//!   with collections67//!68//! ## Interface69//!70//! ### Dispatchable Functions71//!72//! - `init_collection` - Create NFT collection. NFT collection can be configured to allow or deny access for73//!   some accounts.74//! - `destroy_collection` - Destroy exising NFT collection. There should be no tokens in the collection.75//! - `burn` - Burn NFT token owned by account.76//! - `transfer` - Transfer NFT token. Transfers should be enabled for NFT collection.77//!   Nests the NFT token if it is sent to another token.78//! - `create_item` - Mint NFT token in collection. Sender should have permission to mint tokens.79//! - `set_allowance` - Set allowance for another account.80//! - `set_token_property` - Set token property value.81//! - `delete_token_property` - Remove property from the token.82//! - `set_collection_properties` - Set collection properties.83//! - `delete_collection_properties` - Remove properties from the collection.84//! - `set_property_permission` - Set collection property permission.85//! - `set_token_property_permissions` - Set token property permissions.86//!87//! ## Assumptions88//!89//! * To perform operations on tokens sender should be in collection's allow list if collection access mode is `AllowList`.9091#![cfg_attr(not(feature = "std"), no_std)]9293use erc::ERC721Events;94use evm_coder::ToLog;95use frame_support::{96	BoundedVec, ensure, fail, transactional,97	storage::with_transaction,98	pallet_prelude::DispatchResultWithPostInfo,99	pallet_prelude::Weight,100	weights::{PostDispatchInfo, Pays},101};102use up_data_structs::{103	AccessMode, CollectionId, CollectionFlags, CustomDataLimit, TokenId, CreateCollectionData,104	CreateNftExData, mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission,105	PropertyKey, PropertyValue, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty,106	TokenChild, AuxPropertyValue,107};108use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};109use pallet_common::{110	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,111	eth::collection_id_to_address,112};113use pallet_structure::{Pallet as PalletStructure, Error as StructureError};114use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};115use sp_core::H160;116use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};117use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};118use core::ops::Deref;119use codec::{Encode, Decode, MaxEncodedLen};120use scale_info::TypeInfo;121122pub use pallet::*;123use weights::WeightInfo;124#[cfg(feature = "runtime-benchmarks")]125pub mod benchmarking;126pub mod common;127pub mod erc;128pub mod weights;129130pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;131pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;132133/// Token data, stored independently from other data used to describe it134/// for the convenience of database access. Notably contains the owner account address.135#[struct_versioning::versioned(version = 2, upper)]136#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]137pub struct ItemData<CrossAccountId> {138	#[version(..2)]139	pub const_data: BoundedVec<u8, CustomDataLimit>,140141	#[version(..2)]142	pub variable_data: BoundedVec<u8, CustomDataLimit>,143144	pub owner: CrossAccountId,145}146147#[frame_support::pallet]148pub mod pallet {149	use super::*;150	use frame_support::{151		Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key, traits::StorageVersion,152	};153	use frame_system::pallet_prelude::*;154	use up_data_structs::{CollectionId, TokenId};155	use super::weights::WeightInfo;156157	#[pallet::error]158	pub enum Error<T> {159		/// Not Nonfungible item data used to mint in Nonfungible collection.160		NotNonfungibleDataUsedToMintFungibleCollectionToken,161		/// Used amount > 1 with NFT162		NonfungibleItemsHaveNoAmount,163		/// Unable to burn NFT with children164		CantBurnNftWithChildren,165	}166167	#[pallet::config]168	pub trait Config:169		frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config170	{171		type WeightInfo: WeightInfo;172	}173174	const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);175176	#[pallet::pallet]177	#[pallet::storage_version(STORAGE_VERSION)]178	#[pallet::generate_store(pub(super) trait Store)]179	pub struct Pallet<T>(_);180181	/// Total amount of minted tokens in a collection.182	#[pallet::storage]183	pub type TokensMinted<T: Config> =184		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;185186	/// Amount of burnt tokens in a collection.187	#[pallet::storage]188	pub type TokensBurnt<T: Config> =189		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;190191	/// Token data, used to partially describe a token.192	#[pallet::storage]193	pub type TokenData<T: Config> = StorageNMap<194		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),195		Value = ItemData<T::CrossAccountId>,196		QueryKind = OptionQuery,197	>;198199	/// Map of key-value pairs, describing the metadata of a token.200	#[pallet::storage]201	#[pallet::getter(fn token_properties)]202	pub type TokenProperties<T: Config> = StorageNMap<203		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),204		Value = Properties,205		QueryKind = ValueQuery,206		OnEmpty = up_data_structs::TokenProperties,207	>;208209	/// Custom data of a token that is serialized to bytes,210	/// primarily reserved for on-chain operations,211	/// normally obscured from the external users.212	///213	/// Auxiliary properties are slightly different from214	/// usual [`TokenProperties`] due to an unlimited number215	/// and separately stored and written-to key-value pairs.216	///217	/// Currently used to store RMRK data.218	#[pallet::storage]219	#[pallet::getter(fn token_aux_property)]220	pub type TokenAuxProperties<T: Config> = StorageNMap<221		Key = (222			Key<Twox64Concat, CollectionId>,223			Key<Twox64Concat, TokenId>,224			Key<Twox64Concat, PropertyScope>,225			Key<Twox64Concat, PropertyKey>,226		),227		Value = AuxPropertyValue,228		QueryKind = OptionQuery,229	>;230231	/// Used to enumerate tokens owned by account.232	#[pallet::storage]233	pub type Owned<T: Config> = StorageNMap<234		Key = (235			Key<Twox64Concat, CollectionId>,236			Key<Blake2_128Concat, T::CrossAccountId>,237			Key<Twox64Concat, TokenId>,238		),239		Value = bool,240		QueryKind = ValueQuery,241	>;242243	/// Used to enumerate token's children.244	#[pallet::storage]245	#[pallet::getter(fn token_children)]246	pub type TokenChildren<T: Config> = StorageNMap<247		Key = (248			Key<Twox64Concat, CollectionId>,249			Key<Twox64Concat, TokenId>,250			Key<Twox64Concat, (CollectionId, TokenId)>,251		),252		Value = bool,253		QueryKind = ValueQuery,254	>;255256	/// Amount of tokens owned by an account in a collection.257	#[pallet::storage]258	pub type AccountBalance<T: Config> = StorageNMap<259		Key = (260			Key<Twox64Concat, CollectionId>,261			Key<Blake2_128Concat, T::CrossAccountId>,262		),263		Value = u32,264		QueryKind = ValueQuery,265	>;266267	/// Allowance set by a token owner for another user to perform one of certain transactions on a token.268	#[pallet::storage]269	pub type Allowance<T: Config> = StorageNMap<270		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),271		Value = T::CrossAccountId,272		QueryKind = OptionQuery,273	>;274275	/// Upgrade from the old schema to properties.276	#[pallet::hooks]277	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {278		fn on_runtime_upgrade() -> Weight {279			StorageVersion::new(1).put::<Pallet<T>>();280281			Weight::zero()282		}283	}284}285286pub struct NonfungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);287impl<T: Config> NonfungibleHandle<T> {288	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {289		Self(inner)290	}291	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {292		self.0293	}294	pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {295		&mut self.0296	}297}298299impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {300	fn recorder(&self) -> &SubstrateRecorder<T> {301		self.0.recorder()302	}303	fn into_recorder(self) -> SubstrateRecorder<T> {304		self.0.into_recorder()305	}306}307impl<T: Config> Deref for NonfungibleHandle<T> {308	type Target = pallet_common::CollectionHandle<T>;309310	fn deref(&self) -> &Self::Target {311		&self.0312	}313}314315impl<T: Config> Pallet<T> {316	/// Get number of NFT tokens in collection.317	pub fn total_supply(collection: &NonfungibleHandle<T>) -> u32 {318		<TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)319	}320321	/// Check that NFT token exists.322	///323	/// - `token`: Token ID.324	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {325		<TokenData<T>>::contains_key((collection.id, token))326	}327328	/// Set the token property with the scope.329	///330	/// - `property`: Contains key-value pair.331	pub fn set_scoped_token_property(332		collection_id: CollectionId,333		token_id: TokenId,334		scope: PropertyScope,335		property: Property,336	) -> DispatchResult {337		TokenProperties::<T>::try_mutate((collection_id, token_id), |properties| {338			properties.try_scoped_set(scope, property.key, property.value)339		})340		.map_err(<CommonError<T>>::from)?;341342		Ok(())343	}344345	/// Batch operation to set multiple properties with the same scope.346	pub fn set_scoped_token_properties(347		collection_id: CollectionId,348		token_id: TokenId,349		scope: PropertyScope,350		properties: impl Iterator<Item = Property>,351	) -> DispatchResult {352		TokenProperties::<T>::try_mutate((collection_id, token_id), |stored_properties| {353			stored_properties.try_scoped_set_from_iter(scope, properties)354		})355		.map_err(<CommonError<T>>::from)?;356357		Ok(())358	}359360	/// Add or edit auxiliary data for the property.361	///362	/// - `f`: function that adds or edits auxiliary data.363	pub fn try_mutate_token_aux_property<R, E>(364		collection_id: CollectionId,365		token_id: TokenId,366		scope: PropertyScope,367		key: PropertyKey,368		f: impl FnOnce(&mut Option<AuxPropertyValue>) -> Result<R, E>,369	) -> Result<R, E> {370		<TokenAuxProperties<T>>::try_mutate((collection_id, token_id, scope, key), f)371	}372373	/// Remove auxiliary data for the property.374	pub fn remove_token_aux_property(375		collection_id: CollectionId,376		token_id: TokenId,377		scope: PropertyScope,378		key: PropertyKey,379	) {380		<TokenAuxProperties<T>>::remove((collection_id, token_id, scope, key));381	}382383	/// Get all auxiliary data in a given scope.384	///385	/// Returns iterator over Property Key - Data pairs.386	pub fn iterate_token_aux_properties(387		collection_id: CollectionId,388		token_id: TokenId,389		scope: PropertyScope,390	) -> impl Iterator<Item = (PropertyKey, AuxPropertyValue)> {391		<TokenAuxProperties<T>>::iter_prefix((collection_id, token_id, scope))392	}393394	/// Get ID of the last minted token395	pub fn current_token_id(collection_id: CollectionId) -> TokenId {396		TokenId(<TokensMinted<T>>::get(collection_id))397	}398}399400// unchecked calls skips any permission checks401impl<T: Config> Pallet<T> {402	/// Create NFT collection403	///404	/// `init_collection` will take non-refundable deposit for collection creation.405	///406	/// - `data`: Contains settings for collection limits and permissions.407	pub fn init_collection(408		owner: T::CrossAccountId,409		payer: T::CrossAccountId,410		data: CreateCollectionData<T::AccountId>,411		flags: CollectionFlags,412	) -> Result<CollectionId, DispatchError> {413		<PalletCommon<T>>::init_collection(owner, payer, data, flags)414	}415416	/// Destroy NFT collection417	///418	/// `destroy_collection` will throw error if collection contains any tokens.419	/// Only owner can destroy collection.420	pub fn destroy_collection(421		collection: NonfungibleHandle<T>,422		sender: &T::CrossAccountId,423	) -> DispatchResult {424		let id = collection.id;425426		if Self::collection_has_tokens(id) {427			return Err(<CommonError<T>>::CantDestroyNotEmptyCollection.into());428		}429430		// =========431432		PalletCommon::destroy_collection(collection.0, sender)?;433434		let _ = <TokenData<T>>::clear_prefix((id,), u32::MAX, None);435		let _ = <TokenChildren<T>>::clear_prefix((id,), u32::MAX, None);436		let _ = <Owned<T>>::clear_prefix((id,), u32::MAX, None);437		<TokensMinted<T>>::remove(id);438		<TokensBurnt<T>>::remove(id);439		let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);440		let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);441		Ok(())442	}443444	/// Burn NFT token445	///446	/// `burn` removes `token` from the `collection`, from it's owner and from the parent token447	/// if the token is nested.448	/// Only the owner can `burn` the token. The `token` shouldn't have any nested tokens.449	/// Also removes all corresponding properties and auxiliary properties.450	///451	/// - `token`: Token that should be burned452	/// - `collection`: Collection that contains the token453	pub fn burn(454		collection: &NonfungibleHandle<T>,455		sender: &T::CrossAccountId,456		token: TokenId,457	) -> DispatchResult {458		let token_data =459			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;460		ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);461462		if collection.permissions.access() == AccessMode::AllowList {463			collection.check_allowlist(sender)?;464		}465466		if Self::token_has_children(collection.id, token) {467			return Err(<Error<T>>::CantBurnNftWithChildren.into());468		}469470		let burnt = <TokensBurnt<T>>::get(collection.id)471			.checked_add(1)472			.ok_or(ArithmeticError::Overflow)?;473474		let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))475			.checked_sub(1)476			.ok_or(ArithmeticError::Overflow)?;477478		// =========479480		if balance == 0 {481			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));482		} else {483			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);484		}485486		<PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);487488		<Owned<T>>::remove((collection.id, &token_data.owner, token));489		<TokensBurnt<T>>::insert(collection.id, burnt);490		<TokenData<T>>::remove((collection.id, token));491		<TokenProperties<T>>::remove((collection.id, token));492		let _ = <TokenAuxProperties<T>>::clear_prefix((collection.id, token), u32::MAX, None);493		let old_spender = <Allowance<T>>::take((collection.id, token));494495		if let Some(old_spender) = old_spender {496			<PalletCommon<T>>::deposit_event(CommonEvent::Approved(497				collection.id,498				token,499				token_data.owner.clone(),500				old_spender,501				0,502			));503		}504505		<PalletEvm<T>>::deposit_log(506			ERC721Events::Transfer {507				from: *token_data.owner.as_eth(),508				to: H160::default(),509				token_id: token.into(),510			}511			.to_log(collection_id_to_address(collection.id)),512		);513		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(514			collection.id,515			token,516			token_data.owner,517			1,518		));519		Ok(())520	}521522	/// Same as [`burn`] but burns all the tokens that are nested in the token first523	///524	/// - `self_budget`: Limit for searching children in depth.525	/// - `breadth_budget`: Limit of breadth of searching children.526	///527	/// [`burn`]: struct.Pallet.html#method.burn528	#[transactional]529	pub fn burn_recursively(530		collection: &NonfungibleHandle<T>,531		sender: &T::CrossAccountId,532		token: TokenId,533		self_budget: &dyn Budget,534		breadth_budget: &dyn Budget,535	) -> DispatchResultWithPostInfo {536		ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);537538		let current_token_account =539			T::CrossTokenAddressMapping::token_to_address(collection.id, token);540541		let mut weight = Weight::zero();542543		// This method is transactional, if user in fact doesn't have permissions to remove token -544		// tokens removed here will be restored after rejected transaction545		for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {546			ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);547			let PostDispatchInfo { actual_weight, .. } =548				<PalletStructure<T>>::burn_item_recursively(549					current_token_account.clone(),550					collection,551					token,552					self_budget,553					breadth_budget,554				)?;555			if let Some(actual_weight) = actual_weight {556				weight = weight.saturating_add(actual_weight);557			}558		}559560		Self::burn(collection, sender, token)?;561		DispatchResultWithPostInfo::Ok(PostDispatchInfo {562			actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),563			pays_fee: Pays::Yes,564		})565	}566567	/// Batch operation to add, edit or remove properties for the token568	///569	/// All affected properties should have mutable permission and sender should have570	/// permission to edit those properties.571	///572	/// - `nesting_budget`: Limit for searching parents in depth to check ownership.573	/// - `is_token_create`: Indicates that method is called during token initialization.574	///   Allows to bypass ownership check.575	#[transactional]576	fn modify_token_properties(577		collection: &NonfungibleHandle<T>,578		sender: &T::CrossAccountId,579		token_id: TokenId,580		properties: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,581		is_token_create: bool,582		nesting_budget: &dyn Budget,583	) -> DispatchResult {584		let mut collection_admin_status = None;585		let mut token_owner_result = None;586587		let mut is_collection_admin =588			|| *collection_admin_status.get_or_insert_with(|| collection.is_owner_or_admin(sender));589590		let mut is_token_owner = || {591			*token_owner_result.get_or_insert_with(|| -> Result<bool, DispatchError> {592				let is_owned = <PalletStructure<T>>::check_indirectly_owned(593					sender.clone(),594					collection.id,595					token_id,596					None,597					nesting_budget,598				)?;599600				Ok(is_owned)601			})602		};603604		for (key, value) in properties {605			let permission = <PalletCommon<T>>::property_permissions(collection.id)606				.get(&key)607				.cloned()608				.unwrap_or_else(PropertyPermission::none);609610			let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))611				.get(&key)612				.is_some();613614			match permission {615				PropertyPermission { mutable: false, .. } if is_property_exists => {616					return Err(<CommonError<T>>::NoPermission.into());617				}618619				PropertyPermission {620					collection_admin,621					token_owner,622					..623				} => {624					//TODO: investigate threats during public minting.625					if is_token_create && (collection_admin || token_owner) && value.is_some() {626						// Pass627					} else if collection_admin && is_collection_admin() {628						// Pass629					} else if token_owner && is_token_owner()? {630						// Pass631					} else {632						fail!(<CommonError<T>>::NoPermission);633					}634				}635			}636637			match value {638				Some(value) => {639					<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {640						properties.try_set(key.clone(), value)641					})642					.map_err(<CommonError<T>>::from)?;643644					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(645						collection.id,646						token_id,647						key,648					));649				}650				None => {651					<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {652						properties.remove(&key)653					})654					.map_err(<CommonError<T>>::from)?;655656					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(657						collection.id,658						token_id,659						key,660					));661				}662			}663		}664665		Ok(())666	}667668	/// Batch operation to add or edit properties for the token669	///670	/// Same as [`modify_token_properties`] but doesn't allow to remove properties671	///672	/// [`modify_token_properties`]: struct.Pallet.html#method.modify_token_properties673	pub fn set_token_properties(674		collection: &NonfungibleHandle<T>,675		sender: &T::CrossAccountId,676		token_id: TokenId,677		properties: impl Iterator<Item = Property>,678		is_token_create: bool,679		nesting_budget: &dyn Budget,680	) -> DispatchResult {681		Self::modify_token_properties(682			collection,683			sender,684			token_id,685			properties.map(|p| (p.key, Some(p.value))),686			is_token_create,687			nesting_budget,688		)689	}690691	/// Add or edit single property for the token692	///693	/// Calls [`set_token_properties`] internally694	///695	/// [`set_token_properties`]: struct.Pallet.html#method.set_token_properties696	pub fn set_token_property(697		collection: &NonfungibleHandle<T>,698		sender: &T::CrossAccountId,699		token_id: TokenId,700		property: Property,701		nesting_budget: &dyn Budget,702	) -> DispatchResult {703		let is_token_create = false;704705		Self::set_token_properties(706			collection,707			sender,708			token_id,709			[property].into_iter(),710			is_token_create,711			nesting_budget,712		)713	}714715	/// Batch operation to remove properties from the token716	///717	/// Same as [`modify_token_properties`] but doesn't allow to add or edit properties718	///719	/// [`modify_token_properties`]: struct.Pallet.html#method.modify_token_properties720	pub fn delete_token_properties(721		collection: &NonfungibleHandle<T>,722		sender: &T::CrossAccountId,723		token_id: TokenId,724		property_keys: impl Iterator<Item = PropertyKey>,725		nesting_budget: &dyn Budget,726	) -> DispatchResult {727		let is_token_create = false;728729		Self::modify_token_properties(730			collection,731			sender,732			token_id,733			property_keys.into_iter().map(|key| (key, None)),734			is_token_create,735			nesting_budget,736		)737	}738739	/// Remove single property from the token740	///741	/// Calls [`delete_token_properties`] internally742	///743	/// [`delete_token_properties`]: struct.Pallet.html#method.delete_token_properties744	pub fn delete_token_property(745		collection: &NonfungibleHandle<T>,746		sender: &T::CrossAccountId,747		token_id: TokenId,748		property_key: PropertyKey,749		nesting_budget: &dyn Budget,750	) -> DispatchResult {751		Self::delete_token_properties(752			collection,753			sender,754			token_id,755			[property_key].into_iter(),756			nesting_budget,757		)758	}759760	/// Add or edit properties for the collection761	pub fn set_collection_properties(762		collection: &NonfungibleHandle<T>,763		sender: &T::CrossAccountId,764		properties: Vec<Property>,765	) -> DispatchResult {766		<PalletCommon<T>>::set_collection_properties(collection, sender, properties)767	}768769	/// Remove properties from the collection770	pub fn delete_collection_properties(771		collection: &CollectionHandle<T>,772		sender: &T::CrossAccountId,773		property_keys: Vec<PropertyKey>,774	) -> DispatchResult {775		<PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)776	}777778	/// Set property permissions for the token.779	///780	/// Sender should be the owner or admin of token's collection.781	pub fn set_token_property_permissions(782		collection: &CollectionHandle<T>,783		sender: &T::CrossAccountId,784		property_permissions: Vec<PropertyKeyPermission>,785	) -> DispatchResult {786		<PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)787	}788789	/// Set property permissions for the token with scope.790	///791	/// Sender should be the owner or admin of token's collection.792	pub fn set_scoped_token_property_permissions(793		collection: &CollectionHandle<T>,794		sender: &T::CrossAccountId,795		scope: PropertyScope,796		property_permissions: Vec<PropertyKeyPermission>,797	) -> DispatchResult {798		<PalletCommon<T>>::set_scoped_token_property_permissions(799			collection,800			sender,801			scope,802			property_permissions,803		)804	}805806	/// Set property permissions for the collection.807	///808	/// Sender should be the owner or admin of the collection.809	pub fn set_property_permission(810		collection: &CollectionHandle<T>,811		sender: &T::CrossAccountId,812		permission: PropertyKeyPermission,813	) -> DispatchResult {814		<PalletCommon<T>>::set_property_permission(collection, sender, permission)815	}816817	/// Transfer NFT token from one account to another.818	///819	/// `from` account stops being the owner and `to` account becomes the owner of the token.820	/// If `to` is token than `to` becomes owner of the token and the token become nested.821	/// Unnests token from previous parent if it was nested before.822	/// Removes allowance for the token if there was any.823	/// Throws if transfers aren't allowed for collection or if receiver reached token ownership limit.824	///825	/// - `nesting_budget`: Limit for token nesting depth826	pub fn transfer(827		collection: &NonfungibleHandle<T>,828		from: &T::CrossAccountId,829		to: &T::CrossAccountId,830		token: TokenId,831		nesting_budget: &dyn Budget,832	) -> DispatchResult {833		ensure!(834			collection.limits.transfers_enabled(),835			<CommonError<T>>::TransferNotAllowed836		);837838		let token_data =839			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;840		ensure!(&token_data.owner == from, <CommonError<T>>::NoPermission);841842		if collection.permissions.access() == AccessMode::AllowList {843			collection.check_allowlist(from)?;844			collection.check_allowlist(to)?;845		}846		<PalletCommon<T>>::ensure_correct_receiver(to)?;847848		let balance_from = <AccountBalance<T>>::get((collection.id, from))849			.checked_sub(1)850			.ok_or(<CommonError<T>>::TokenValueTooLow)?;851		let balance_to = if from != to {852			let balance_to = <AccountBalance<T>>::get((collection.id, to))853				.checked_add(1)854				.ok_or(ArithmeticError::Overflow)?;855856			ensure!(857				balance_to < collection.limits.account_token_ownership_limit(),858				<CommonError<T>>::AccountTokenLimitExceeded,859			);860861			Some(balance_to)862		} else {863			None864		};865866		<PalletStructure<T>>::nest_if_sent_to_token(867			from.clone(),868			to,869			collection.id,870			token,871			nesting_budget,872		)?;873874		// =========875876		<PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);877878		<TokenData<T>>::insert(879			(collection.id, token),880			ItemData {881				owner: to.clone(),882				..token_data883			},884		);885886		if let Some(balance_to) = balance_to {887			// from != to888			if balance_from == 0 {889				<AccountBalance<T>>::remove((collection.id, from));890			} else {891				<AccountBalance<T>>::insert((collection.id, from), balance_from);892			}893			<AccountBalance<T>>::insert((collection.id, to), balance_to);894			<Owned<T>>::remove((collection.id, from, token));895			<Owned<T>>::insert((collection.id, to, token), true);896		}897		Self::set_allowance_unchecked(collection, from, token, None, true);898899		<PalletEvm<T>>::deposit_log(900			ERC721Events::Transfer {901				from: *from.as_eth(),902				to: *to.as_eth(),903				token_id: token.into(),904			}905			.to_log(collection_id_to_address(collection.id)),906		);907		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(908			collection.id,909			token,910			from.clone(),911			to.clone(),912			1,913		));914		Ok(())915	}916917	/// Batch operation to mint multiple NFT tokens.918	///919	/// The sender should be the owner/admin of the collection or collection should be configured920	/// to allow public minting.921	/// Throws if amount of tokens reached it's limit for the collection or if caller reached922	/// token ownership limit.923	///924	/// - `data`: Contains list of token properties and users who will become the owners of the925	///   corresponging tokens.926	/// - `nesting_budget`: Limit for token nesting depth927	pub fn create_multiple_items(928		collection: &NonfungibleHandle<T>,929		sender: &T::CrossAccountId,930		data: Vec<CreateItemData<T>>,931		nesting_budget: &dyn Budget,932	) -> DispatchResult {933		if !collection.is_owner_or_admin(sender) {934			ensure!(935				collection.permissions.mint_mode(),936				<CommonError<T>>::PublicMintingNotAllowed937			);938			collection.check_allowlist(sender)?;939940			for item in data.iter() {941				collection.check_allowlist(&item.owner)?;942			}943		}944945		for data in data.iter() {946			<PalletCommon<T>>::ensure_correct_receiver(&data.owner)?;947		}948949		let first_token = <TokensMinted<T>>::get(collection.id);950		let tokens_minted = first_token951			.checked_add(data.len() as u32)952			.ok_or(ArithmeticError::Overflow)?;953		ensure!(954			tokens_minted <= collection.limits.token_limit(),955			<CommonError<T>>::CollectionTokenLimitExceeded956		);957958		let mut balances = BTreeMap::new();959		for data in &data {960			let balance = balances961				.entry(&data.owner)962				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));963			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;964965			ensure!(966				*balance <= collection.limits.account_token_ownership_limit(),967				<CommonError<T>>::AccountTokenLimitExceeded,968			);969		}970971		for (i, data) in data.iter().enumerate() {972			let token = TokenId(first_token + i as u32 + 1);973974			<PalletStructure<T>>::check_nesting(975				sender.clone(),976				&data.owner,977				collection.id,978				token,979				nesting_budget,980			)?;981		}982983		// =========984985		with_transaction(|| {986			for (i, data) in data.iter().enumerate() {987				let token = first_token + i as u32 + 1;988989				<TokenData<T>>::insert(990					(collection.id, token),991					ItemData {992						// const_data: data.const_data.clone(),993						owner: data.owner.clone(),994					},995				);996997				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(998					&data.owner,999					collection.id,1000					TokenId(token),1001				);10021003				if let Err(e) = Self::set_token_properties(1004					collection,1005					sender,1006					TokenId(token),1007					data.properties.clone().into_iter(),1008					true,1009					nesting_budget,1010				) {1011					return TransactionOutcome::Rollback(Err(e));1012				}1013			}1014			TransactionOutcome::Commit(Ok(()))1015		})?;10161017		<TokensMinted<T>>::insert(collection.id, tokens_minted);1018		for (account, balance) in balances {1019			<AccountBalance<T>>::insert((collection.id, account), balance);1020		}1021		for (i, data) in data.into_iter().enumerate() {1022			let token = first_token + i as u32 + 1;1023			<Owned<T>>::insert((collection.id, &data.owner, token), true);10241025			<PalletEvm<T>>::deposit_log(1026				ERC721Events::Transfer {1027					from: H160::default(),1028					to: *data.owner.as_eth(),1029					token_id: token.into(),1030				}1031				.to_log(collection_id_to_address(collection.id)),1032			);1033			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(1034				collection.id,1035				TokenId(token),1036				data.owner.clone(),1037				1,1038			));1039		}1040		Ok(())1041	}10421043	pub fn set_allowance_unchecked(1044		collection: &NonfungibleHandle<T>,1045		sender: &T::CrossAccountId,1046		token: TokenId,1047		spender: Option<&T::CrossAccountId>,1048		assume_implicit_eth: bool,1049	) {1050		if let Some(spender) = spender {1051			let old_spender = <Allowance<T>>::get((collection.id, token));1052			<Allowance<T>>::insert((collection.id, token), spender);1053			// In ERC721 there is only one possible approved user of token, so we set1054			// approved user to spender1055			<PalletEvm<T>>::deposit_log(1056				ERC721Events::Approval {1057					owner: *sender.as_eth(),1058					approved: *spender.as_eth(),1059					token_id: token.into(),1060				}1061				.to_log(collection_id_to_address(collection.id)),1062			);1063			// In Unique chain, any token can have any amount of approved users, so we need to1064			// set allowance of old owner to 0, and allowance of new owner to 11065			if old_spender.as_ref() != Some(spender) {1066				if let Some(old_owner) = old_spender {1067					<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1068						collection.id,1069						token,1070						sender.clone(),1071						old_owner,1072						0,1073					));1074				}1075				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1076					collection.id,1077					token,1078					sender.clone(),1079					spender.clone(),1080					1,1081				));1082			}1083		} else {1084			let old_spender = <Allowance<T>>::take((collection.id, token));1085			if !assume_implicit_eth {1086				// In ERC721 there is only one possible approved user of token, so we set1087				// approved user to zero address1088				<PalletEvm<T>>::deposit_log(1089					ERC721Events::Approval {1090						owner: *sender.as_eth(),1091						approved: H160::default(),1092						token_id: token.into(),1093					}1094					.to_log(collection_id_to_address(collection.id)),1095				);1096			}1097			// In Unique chain, any token can have any amount of approved users, so we need to1098			// set allowance of old owner to 01099			if let Some(old_spender) = old_spender {1100				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(1101					collection.id,1102					token,1103					sender.clone(),1104					old_spender,1105					0,1106				));1107			}1108		}1109	}11101111	/// Set allowance for the spender to `transfer` or `burn` sender's token.1112	///1113	/// - `token`: Token the spender is allowed to `transfer` or `burn`.1114	pub fn set_allowance(1115		collection: &NonfungibleHandle<T>,1116		sender: &T::CrossAccountId,1117		token: TokenId,1118		spender: Option<&T::CrossAccountId>,1119	) -> DispatchResult {1120		if collection.permissions.access() == AccessMode::AllowList {1121			collection.check_allowlist(sender)?;1122			if let Some(spender) = spender {1123				collection.check_allowlist(spender)?;1124			}1125		}11261127		if let Some(spender) = spender {1128			<PalletCommon<T>>::ensure_correct_receiver(spender)?;1129		}11301131		let token_data =1132			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;1133		if &token_data.owner != sender {1134			ensure!(1135				collection.ignores_owned_amount(sender),1136				<CommonError<T>>::CantApproveMoreThanOwned1137			);1138		}11391140		// =========11411142		Self::set_allowance_unchecked(collection, sender, token, spender, false);1143		Ok(())1144	}11451146	/// Checks allowance for the spender to use the token.1147	fn check_allowed(1148		collection: &NonfungibleHandle<T>,1149		spender: &T::CrossAccountId,1150		from: &T::CrossAccountId,1151		token: TokenId,1152		nesting_budget: &dyn Budget,1153	) -> DispatchResult {1154		if spender.conv_eq(from) {1155			return Ok(());1156		}1157		if collection.permissions.access() == AccessMode::AllowList {1158			// `from`, `to` checked in [`transfer`]1159			collection.check_allowlist(spender)?;1160		}11611162		if collection.limits.owner_can_transfer() && collection.is_owner_or_admin(spender) {1163			return Ok(());1164		}11651166		if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {1167			ensure!(1168				<PalletStructure<T>>::check_indirectly_owned(1169					spender.clone(),1170					source.0,1171					source.1,1172					None,1173					nesting_budget1174				)?,1175				<CommonError<T>>::ApprovedValueTooLow,1176			);1177			return Ok(());1178		}1179		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {1180			return Ok(());1181		}1182		ensure!(1183			collection.ignores_allowance(spender),1184			<CommonError<T>>::ApprovedValueTooLow1185		);1186		Ok(())1187	}11881189	/// Transfer NFT token from one account to another.1190	///1191	/// Same as the [`transfer`] but spender doesn't needs to be the owner of the token.1192	/// The owner should set allowance for the spender to transfer token.1193	///1194	/// [`transfer`]: struct.Pallet.html#method.transfer1195	pub fn transfer_from(1196		collection: &NonfungibleHandle<T>,1197		spender: &T::CrossAccountId,1198		from: &T::CrossAccountId,1199		to: &T::CrossAccountId,1200		token: TokenId,1201		nesting_budget: &dyn Budget,1202	) -> DispatchResult {1203		Self::check_allowed(collection, spender, from, token, nesting_budget)?;12041205		// =========12061207		// Allowance is reset in [`transfer`]1208		Self::transfer(collection, from, to, token, nesting_budget)1209	}12101211	/// Burn NFT token for `from` account.1212	///1213	/// Same as the [`burn`] but spender doesn't need to be an owner of the token. The owner should1214	/// set allowance for the spender to burn token.1215	///1216	/// [`burn`]: struct.Pallet.html#method.burn1217	pub fn burn_from(1218		collection: &NonfungibleHandle<T>,1219		spender: &T::CrossAccountId,1220		from: &T::CrossAccountId,1221		token: TokenId,1222		nesting_budget: &dyn Budget,1223	) -> DispatchResult {1224		Self::check_allowed(collection, spender, from, token, nesting_budget)?;12251226		// =========12271228		Self::burn(collection, from, token)1229	}12301231	/// Check that `from` token could be nested in `under` token.1232	///1233	pub fn check_nesting(1234		handle: &NonfungibleHandle<T>,1235		sender: T::CrossAccountId,1236		from: (CollectionId, TokenId),1237		under: TokenId,1238		nesting_budget: &dyn Budget,1239	) -> DispatchResult {1240		let nesting = handle.permissions.nesting();12411242		#[cfg(not(feature = "runtime-benchmarks"))]1243		let permissive = false;1244		#[cfg(feature = "runtime-benchmarks")]1245		let permissive = nesting.permissive;12461247		if permissive {1248			// Pass1249		} else if nesting.token_owner1250			&& <PalletStructure<T>>::check_indirectly_owned(1251				sender.clone(),1252				handle.id,1253				under,1254				Some(from),1255				nesting_budget,1256			)? {1257			// Pass1258		} else if nesting.collection_admin && handle.is_owner_or_admin(&sender) {1259			// Pass1260		} else {1261			fail!(<CommonError<T>>::UserIsNotAllowedToNest);1262		}12631264		if let Some(whitelist) = &nesting.restricted {1265			ensure!(1266				whitelist.contains(&from.0),1267				<CommonError<T>>::SourceCollectionIsNotAllowedToNest1268			);1269		}1270		Ok(())1271	}12721273	fn nest(under: (CollectionId, TokenId), to_nest: (CollectionId, TokenId)) {1274		<TokenChildren<T>>::insert((under.0, under.1, (to_nest.0, to_nest.1)), true);1275	}12761277	fn unnest(under: (CollectionId, TokenId), to_unnest: (CollectionId, TokenId)) {1278		<TokenChildren<T>>::remove((under.0, under.1, to_unnest));1279	}12801281	fn collection_has_tokens(collection_id: CollectionId) -> bool {1282		<TokenData<T>>::iter_prefix((collection_id,))1283			.next()1284			.is_some()1285	}12861287	fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {1288		<TokenChildren<T>>::iter_prefix((collection_id, token_id))1289			.next()1290			.is_some()1291	}12921293	pub fn token_children_ids(collection_id: CollectionId, token_id: TokenId) -> Vec<TokenChild> {1294		<TokenChildren<T>>::iter_prefix((collection_id, token_id))1295			.map(|((child_collection_id, child_id), _)| TokenChild {1296				collection: child_collection_id,1297				token: child_id,1298			})1299			.collect()1300	}13011302	/// Mint single NFT token.1303	///1304	/// Delegated to [`create_multiple_items`]1305	///1306	/// [`create_multiple_items`]: struct.Pallet.html#method.create_multiple_items1307	pub fn create_item(1308		collection: &NonfungibleHandle<T>,1309		sender: &T::CrossAccountId,1310		data: CreateItemData<T>,1311		nesting_budget: &dyn Budget,1312	) -> DispatchResult {1313		Self::create_multiple_items(collection, sender, vec![data], nesting_budget)1314	}1315}
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -91,7 +91,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -369,9 +369,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) public {
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) public {
 		require(false, stub_error);
 		newOwner;
 		dummy = 0;
@@ -384,6 +384,49 @@
 	uint256 field_1;
 }
 
+/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
+/// @dev See https://eips.ethereum.org/EIPS/eip-721
+/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
+contract ERC721Metadata is Dummy, ERC165 {
+	// /// @notice A descriptive name for a collection of NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x06fdde03,
+	// ///  or in textual repr: name()
+	// function name() public view returns (string memory) {
+	// 	require(false, stub_error);
+	// 	dummy;
+	// 	return "";
+	// }
+
+	// /// @notice An abbreviated name for NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x95d89b41,
+	// ///  or in textual repr: symbol()
+	// function symbol() public view returns (string memory) {
+	// 	require(false, stub_error);
+	// 	dummy;
+	// 	return "";
+	// }
+
+	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+	///
+	/// @dev If the token has a `url` property and it is not empty, it is returned.
+	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
+	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
+	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+	///
+	/// @return token's const_metadata
+	/// @dev EVM selector for this function is: 0xc87b56dd,
+	///  or in textual repr: tokenURI(uint256)
+	function tokenURI(uint256 tokenId) public view returns (string memory) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return "";
+	}
+}
+
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 contract ERC721Burnable is Dummy, ERC165 {
@@ -401,13 +444,13 @@
 }
 
 /// @dev inlined interface
-contract ERC721MintableEvents {
+contract ERC721UniqueMintableEvents {
 	event MintingFinished();
 }
 
 /// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x68ccfe89
-contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
+/// @dev the ERC-165 identifier for this interface is 0x476ff149
+contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
 	/// @dev EVM selector for this function is: 0x05d2035b,
 	///  or in textual repr: mintingFinished()
 	function mintingFinished() public view returns (bool) {
@@ -417,41 +460,63 @@
 	}
 
 	/// @notice Function to mint token.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted NFT
-	/// @dev EVM selector for this function is: 0x40c10f19,
-	///  or in textual repr: mint(address,uint256)
-	function mint(address to, uint256 tokenId) public returns (bool) {
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x6a627842,
+	///  or in textual repr: mint(address)
+	function mint(address to) public returns (uint256) {
 		require(false, stub_error);
 		to;
-		tokenId;
 		dummy = 0;
-		return false;
+		return 0;
 	}
 
+	// /// @notice Function to mint token.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted NFT
+	// /// @dev EVM selector for this function is: 0x40c10f19,
+	// ///  or in textual repr: mint(address,uint256)
+	// function mint(address to, uint256 tokenId) public returns (bool) {
+	// 	require(false, stub_error);
+	// 	to;
+	// 	tokenId;
+	// 	dummy = 0;
+	// 	return false;
+	// }
+
 	/// @notice Function to mint token with the given tokenUri.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted NFT
 	/// @param tokenUri Token URI that would be stored in the NFT properties
-	/// @dev EVM selector for this function is: 0x50bb4e7f,
-	///  or in textual repr: mintWithTokenURI(address,uint256,string)
-	function mintWithTokenURI(
-		address to,
-		uint256 tokenId,
-		string memory tokenUri
-	) public returns (bool) {
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x45c17782,
+	///  or in textual repr: mintWithTokenURI(address,string)
+	function mintWithTokenURI(address to, string memory tokenUri) public returns (uint256) {
 		require(false, stub_error);
 		to;
-		tokenId;
 		tokenUri;
 		dummy = 0;
-		return false;
+		return 0;
 	}
 
+	// /// @notice Function to mint token with the given tokenUri.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted NFT
+	// /// @param tokenUri Token URI that would be stored in the NFT properties
+	// /// @dev EVM selector for this function is: 0x50bb4e7f,
+	// ///  or in textual repr: mintWithTokenURI(address,uint256,string)
+	// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) public returns (bool) {
+	// 	require(false, stub_error);
+	// 	to;
+	// 	tokenId;
+	// 	tokenUri;
+	// 	dummy = 0;
+	// 	return false;
+	// }
+
 	/// @dev Not implemented
 	/// @dev EVM selector for this function is: 0x7d64bcb4,
 	///  or in textual repr: finishMinting()
@@ -463,8 +528,26 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xd74d154f
+/// @dev the ERC-165 identifier for this interface is 0x4468500d
 contract ERC721UniqueExtensions is Dummy, ERC165 {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	/// @dev EVM selector for this function is: 0x06fdde03,
+	///  or in textual repr: name()
+	function name() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	/// @notice An abbreviated name for NFTs in this contract
+	/// @dev EVM selector for this function is: 0x95d89b41,
+	///  or in textual repr: symbol()
+	function symbol() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -525,7 +608,7 @@
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	/// @dev EVM selector for this function is: 0x36543006,
 	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {
+	function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {
 		require(false, stub_error);
 		to;
 		tokens;
@@ -535,7 +618,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple8 {
+struct Tuple6 {
 	uint256 field_0;
 	string field_1;
 }
@@ -579,48 +662,7 @@
 		return 0;
 	}
 }
-
-/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
-/// @dev See https://eips.ethereum.org/EIPS/eip-721
-/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
-contract ERC721Metadata is Dummy, ERC165 {
-	/// @notice A descriptive name for a collection of NFTs in this contract
-	/// @dev EVM selector for this function is: 0x06fdde03,
-	///  or in textual repr: name()
-	function name() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-
-	/// @notice An abbreviated name for NFTs in this contract
-	/// @dev EVM selector for this function is: 0x95d89b41,
-	///  or in textual repr: symbol()
-	function symbol() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
 
-	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
-	///
-	/// @dev If the token has a `url` property and it is not empty, it is returned.
-	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
-	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
-	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
-	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
-	///
-	/// @return token's const_metadata
-	/// @dev EVM selector for this function is: 0xc87b56dd,
-	///  or in textual repr: tokenURI(uint256)
-	function tokenURI(uint256 tokenId) public view returns (string memory) {
-		require(false, stub_error);
-		tokenId;
-		dummy;
-		return "";
-	}
-}
-
 /// @dev inlined interface
 contract ERC721Events {
 	event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
@@ -766,11 +808,11 @@
 	Dummy,
 	ERC165,
 	ERC721,
-	ERC721Metadata,
 	ERC721Enumerable,
 	ERC721UniqueExtensions,
-	ERC721Mintable,
+	ERC721UniqueMintable,
 	ERC721Burnable,
+	ERC721Metadata,
 	Collection,
 	TokenProperties
 {}
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -1448,7 +1448,15 @@
 		data: CreateCollectionData<T::AccountId>,
 		properties: impl Iterator<Item = Property>,
 	) -> Result<CollectionId, DispatchError> {
-		let collection_id = <PalletNft<T>>::init_collection(sender.clone(), sender, data, true);
+		let collection_id = <PalletNft<T>>::init_collection(
+			sender.clone(),
+			sender,
+			data,
+			up_data_structs::CollectionFlags {
+				external: true,
+				..Default::default()
+			},
+		);
 
 		if let Err(DispatchError::Arithmetic(_)) = &collection_id {
 			return Err(<Error<T>>::NoAvailableCollectionId.into());
modifiedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-equip/src/lib.rs
+++ b/pallets/proxy-rmrk-equip/src/lib.rs
@@ -254,7 +254,10 @@
 				cross_sender.clone(),
 				cross_sender.clone(),
 				data,
-				true,
+				up_data_structs::CollectionFlags {
+					external: true,
+					..Default::default()
+				},
 			);
 
 			if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -21,19 +21,15 @@
 
 extern crate alloc;
 
-use alloc::string::ToString;
 use core::{
 	char::{REPLACEMENT_CHARACTER, decode_utf16},
 	convert::TryInto,
 };
 use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
-use frame_support::BoundedBTreeMap;
+use frame_support::{BoundedBTreeMap, BoundedVec};
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions,
-	erc::{
-		CommonEvmHandler, CollectionCall,
-		static_property::{key, value as property_value},
-	},
+	erc::{CommonEvmHandler, CollectionCall, static_property::key},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm};
@@ -191,7 +187,7 @@
 }
 
 #[derive(ToLog)]
-pub enum ERC721MintableEvents {
+pub enum ERC721UniqueMintableEvents {
 	/// @dev Not supported
 	#[allow(dead_code)]
 	MintingFinished {},
@@ -199,16 +195,18 @@
 
 #[solidity_interface(name = ERC721Metadata)]
 impl<T: Config> RefungibleHandle<T> {
-	/// @notice A descriptive name for a collection of RFTs in this contract
-	fn name(&self) -> Result<string> {
-		Ok(decode_utf16(self.name.iter().copied())
-			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
-			.collect::<string>())
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	#[solidity(hide, rename_selector = "name")]
+	fn name_proxy(&self) -> Result<string> {
+		self.name()
 	}
 
-	/// @notice An abbreviated name for RFTs in this contract
-	fn symbol(&self) -> Result<string> {
-		Ok(string::from_utf8_lossy(&self.token_prefix).into())
+	/// @notice An abbreviated name for NFTs in this contract
+	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	#[solidity(hide, rename_selector = "symbol")]
+	fn symbol_proxy(&self) -> Result<string> {
+		self.symbol()
 	}
 
 	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
@@ -224,35 +222,38 @@
 	fn token_uri(&self, token_id: uint256) -> Result<string> {
 		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
 
-		if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {
-			if !url.is_empty() {
-				return Ok(url);
+		match get_token_property(self, token_id_u32, &key::url()).as_deref() {
+			Err(_) | Ok("") => (),
+			Ok(url) => {
+				return Ok(url.into());
 			}
-		} else if !is_erc721_metadata_compatible::<T>(self.id) {
-			return Err("tokenURI not set".into());
-		}
+		};
 
-		if let Some(base_uri) =
+		let base_uri =
 			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())
-		{
-			if !base_uri.is_empty() {
-				let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {
+				.map(BoundedVec::into_inner)
+				.map(string::from_utf8)
+				.transpose()
+				.map_err(|e| {
 					Error::Revert(alloc::format!(
 						"Can not convert value \"baseURI\" to string with error \"{}\"",
 						e
 					))
 				})?;
-				if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {
-					if !suffix.is_empty() {
-						return Ok(base_uri + suffix.as_str());
-					}
-				}
 
-				return Ok(base_uri + token_id.to_string().as_str());
+		let base_uri = match base_uri.as_deref() {
+			None | Some("") => {
+				return Ok("".into());
 			}
-		}
+			Some(base_uri) => base_uri.into(),
+		};
 
-		Ok("".into())
+		Ok(
+			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {
+				Err(_) | Ok("") => base_uri,
+				Ok(suffix) => base_uri + suffix,
+			},
+		)
 	}
 }
 
@@ -448,19 +449,33 @@
 }
 
 /// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
 impl<T: Config> RefungibleHandle<T> {
 	fn minting_finished(&self) -> Result<bool> {
 		Ok(false)
 	}
 
 	/// @notice Function to mint token.
+	/// @param to The new owner
+	/// @return uint256 The id of the newly minted token
+	#[weight(<SelfWeightOf<T>>::create_item())]
+	fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {
+		let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+			.checked_add(1)
+			.ok_or("item id overflow")?
+			.into();
+		self.mint_check_id(caller, to, token_id)?;
+		Ok(token_id)
+	}
+
+	/// @notice Function to mint token.
 	/// @dev `tokenId` should be obtained with `nextTokenId` method,
 	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
 	/// @param tokenId ID of the minted RFT
+	#[solidity(hide, rename_selector = "mint")]
 	#[weight(<SelfWeightOf<T>>::create_item())]
-	fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
+	fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
 		let token_id: u32 = token_id.try_into()?;
@@ -496,14 +511,34 @@
 	}
 
 	/// @notice Function to mint token with the given tokenUri.
+	/// @param to The new owner
+	/// @param tokenUri Token URI that would be stored in the NFT properties
+	/// @return uint256 The id of the newly minted token
+	#[solidity(rename_selector = "mintWithTokenURI")]
+	#[weight(<SelfWeightOf<T>>::create_item())]
+	fn mint_with_token_uri(
+		&mut self,
+		caller: caller,
+		to: address,
+		token_uri: string,
+	) -> Result<uint256> {
+		let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+			.checked_add(1)
+			.ok_or("item id overflow")?
+			.into();
+		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;
+		Ok(token_id)
+	}
+
+	/// @notice Function to mint token with the given tokenUri.
 	/// @dev `tokenId` should be obtained with `nextTokenId` method,
 	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
 	/// @param tokenId ID of the minted RFT
 	/// @param tokenUri Token URI that would be stored in the RFT properties
-	#[solidity(rename_selector = "mintWithTokenURI")]
+	#[solidity(hide, rename_selector = "mintWithTokenURI")]
 	#[weight(<SelfWeightOf<T>>::create_item())]
-	fn mint_with_token_uri(
+	fn mint_with_token_uri_check_id(
 		&mut self,
 		caller: caller,
 		to: address,
@@ -578,17 +613,6 @@
 	Err("Property tokenURI not found".into())
 }
 
-fn is_erc721_metadata_compatible<T: Config>(collection_id: CollectionId) -> bool {
-	if let Some(shema_name) =
-		pallet_common::Pallet::<T>::get_collection_property(collection_id, &key::schema_name())
-	{
-		let shema_name = shema_name.into_inner();
-		shema_name == property_value::ERC721_METADATA
-	} else {
-		false
-	}
-}
-
 fn get_token_permission<T: Config>(
 	collection_id: CollectionId,
 	key: &PropertyKey,
@@ -608,6 +632,18 @@
 /// @title Unique extensions for ERC721.
 #[solidity_interface(name = ERC721UniqueExtensions)]
 impl<T: Config> RefungibleHandle<T> {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	fn name(&self) -> Result<string> {
+		Ok(decode_utf16(self.name.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
+	/// @notice An abbreviated name for NFTs in this contract
+	fn symbol(&self) -> Result<string> {
+		Ok(string::from_utf8_lossy(&self.token_prefix).into())
+	}
+
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
@@ -669,6 +705,7 @@
 	///  should be obtained with `nextTokenId` method
 	/// @param to The new owner
 	/// @param tokenIds IDs of the minted RFTs
+	// #[solidity(hide)]
 	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]
 	fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -711,7 +748,7 @@
 	///  numbers and first number should be obtained with `nextTokenId` method
 	/// @param to The new owner
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
-	#[solidity(rename_selector = "mintBulkWithTokenURI")]
+	#[solidity(/*hide,*/ rename_selector = "mintBulkWithTokenURI")]
 	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
 	fn mint_bulk_with_token_uri(
 		&mut self,
@@ -780,11 +817,11 @@
 	name = UniqueRefungible,
 	is(
 		ERC721,
-		ERC721Metadata,
 		ERC721Enumerable,
 		ERC721UniqueExtensions,
-		ERC721Mintable,
+		ERC721UniqueMintable,
 		ERC721Burnable,
+		ERC721Metadata(if(this.flags.erc721metadata)),
 		Collection(via(common_mut returns CollectionHandle<T>)),
 		TokenProperties,
 	)
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -92,9 +92,11 @@
 
 use codec::{Encode, Decode, MaxEncodedLen};
 use core::ops::Deref;
+use derivative::Derivative;
 use evm_coder::ToLog;
 use frame_support::{
-	BoundedVec, ensure, fail, storage::with_transaction, transactional, pallet_prelude::ConstU32,
+	BoundedBTreeMap, BoundedVec, ensure, fail, storage::with_transaction, transactional,
+	pallet_prelude::ConstU32,
 };
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_evm_coder_substrate::WithRecorder;
@@ -113,8 +115,6 @@
 	MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,
 	PropertyScope, PropertyValue, TokenId, TrySetProperty,
 };
-use frame_support::BoundedBTreeMap;
-use derivative::Derivative;
 
 pub use pallet::*;
 #[cfg(feature = "runtime-benchmarks")]
@@ -371,8 +371,9 @@
 		owner: T::CrossAccountId,
 		payer: T::CrossAccountId,
 		data: CreateCollectionData<T::AccountId>,
+		flags: CollectionFlags,
 	) -> Result<CollectionId, DispatchError> {
-		<PalletCommon<T>>::init_collection(owner, payer, data, CollectionFlags::default())
+		<PalletCommon<T>>::init_collection(owner, payer, data, flags)
 	}
 
 	/// Destroy RFT collection
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -91,7 +91,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -369,9 +369,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) public {
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) public {
 		require(false, stub_error);
 		newOwner;
 		dummy = 0;
@@ -384,6 +384,47 @@
 	uint256 field_1;
 }
 
+/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
+contract ERC721Metadata is Dummy, ERC165 {
+	// /// @notice A descriptive name for a collection of NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x06fdde03,
+	// ///  or in textual repr: name()
+	// function name() public view returns (string memory) {
+	// 	require(false, stub_error);
+	// 	dummy;
+	// 	return "";
+	// }
+
+	// /// @notice An abbreviated name for NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x95d89b41,
+	// ///  or in textual repr: symbol()
+	// function symbol() public view returns (string memory) {
+	// 	require(false, stub_error);
+	// 	dummy;
+	// 	return "";
+	// }
+
+	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+	///
+	/// @dev If the token has a `url` property and it is not empty, it is returned.
+	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
+	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
+	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+	///
+	/// @return token's const_metadata
+	/// @dev EVM selector for this function is: 0xc87b56dd,
+	///  or in textual repr: tokenURI(uint256)
+	function tokenURI(uint256 tokenId) public view returns (string memory) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return "";
+	}
+}
+
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 contract ERC721Burnable is Dummy, ERC165 {
@@ -401,13 +442,13 @@
 }
 
 /// @dev inlined interface
-contract ERC721MintableEvents {
+contract ERC721UniqueMintableEvents {
 	event MintingFinished();
 }
 
 /// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x68ccfe89
-contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
+/// @dev the ERC-165 identifier for this interface is 0x476ff149
+contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
 	/// @dev EVM selector for this function is: 0x05d2035b,
 	///  or in textual repr: mintingFinished()
 	function mintingFinished() public view returns (bool) {
@@ -417,41 +458,63 @@
 	}
 
 	/// @notice Function to mint token.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted RFT
-	/// @dev EVM selector for this function is: 0x40c10f19,
-	///  or in textual repr: mint(address,uint256)
-	function mint(address to, uint256 tokenId) public returns (bool) {
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x6a627842,
+	///  or in textual repr: mint(address)
+	function mint(address to) public returns (uint256) {
 		require(false, stub_error);
 		to;
-		tokenId;
 		dummy = 0;
-		return false;
+		return 0;
 	}
 
+	// /// @notice Function to mint token.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted RFT
+	// /// @dev EVM selector for this function is: 0x40c10f19,
+	// ///  or in textual repr: mint(address,uint256)
+	// function mint(address to, uint256 tokenId) public returns (bool) {
+	// 	require(false, stub_error);
+	// 	to;
+	// 	tokenId;
+	// 	dummy = 0;
+	// 	return false;
+	// }
+
 	/// @notice Function to mint token with the given tokenUri.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted RFT
-	/// @param tokenUri Token URI that would be stored in the RFT properties
-	/// @dev EVM selector for this function is: 0x50bb4e7f,
-	///  or in textual repr: mintWithTokenURI(address,uint256,string)
-	function mintWithTokenURI(
-		address to,
-		uint256 tokenId,
-		string memory tokenUri
-	) public returns (bool) {
+	/// @param tokenUri Token URI that would be stored in the NFT properties
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x45c17782,
+	///  or in textual repr: mintWithTokenURI(address,string)
+	function mintWithTokenURI(address to, string memory tokenUri) public returns (uint256) {
 		require(false, stub_error);
 		to;
-		tokenId;
 		tokenUri;
 		dummy = 0;
-		return false;
+		return 0;
 	}
 
+	// /// @notice Function to mint token with the given tokenUri.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted RFT
+	// /// @param tokenUri Token URI that would be stored in the RFT properties
+	// /// @dev EVM selector for this function is: 0x50bb4e7f,
+	// ///  or in textual repr: mintWithTokenURI(address,uint256,string)
+	// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) public returns (bool) {
+	// 	require(false, stub_error);
+	// 	to;
+	// 	tokenId;
+	// 	tokenUri;
+	// 	dummy = 0;
+	// 	return false;
+	// }
+
 	/// @dev Not implemented
 	/// @dev EVM selector for this function is: 0x7d64bcb4,
 	///  or in textual repr: finishMinting()
@@ -463,8 +526,26 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x7c3bef89
+/// @dev the ERC-165 identifier for this interface is 0xef1eaacb
 contract ERC721UniqueExtensions is Dummy, ERC165 {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	/// @dev EVM selector for this function is: 0x06fdde03,
+	///  or in textual repr: name()
+	function name() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	/// @notice An abbreviated name for NFTs in this contract
+	/// @dev EVM selector for this function is: 0x95d89b41,
+	///  or in textual repr: symbol()
+	function symbol() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
@@ -527,7 +608,7 @@
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	/// @dev EVM selector for this function is: 0x36543006,
 	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {
+	function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {
 		require(false, stub_error);
 		to;
 		tokens;
@@ -549,7 +630,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple8 {
+struct Tuple6 {
 	uint256 field_0;
 	string field_1;
 }
@@ -591,46 +672,7 @@
 		require(false, stub_error);
 		dummy;
 		return 0;
-	}
-}
-
-/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
-contract ERC721Metadata is Dummy, ERC165 {
-	/// @notice A descriptive name for a collection of RFTs in this contract
-	/// @dev EVM selector for this function is: 0x06fdde03,
-	///  or in textual repr: name()
-	function name() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-
-	/// @notice An abbreviated name for RFTs in this contract
-	/// @dev EVM selector for this function is: 0x95d89b41,
-	///  or in textual repr: symbol()
-	function symbol() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
 	}
-
-	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
-	///
-	/// @dev If the token has a `url` property and it is not empty, it is returned.
-	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
-	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
-	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
-	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
-	///
-	/// @return token's const_metadata
-	/// @dev EVM selector for this function is: 0xc87b56dd,
-	///  or in textual repr: tokenURI(uint256)
-	function tokenURI(uint256 tokenId) public view returns (string memory) {
-		require(false, stub_error);
-		tokenId;
-		dummy;
-		return "";
-	}
 }
 
 /// @dev inlined interface
@@ -776,11 +818,11 @@
 	Dummy,
 	ERC165,
 	ERC721,
-	ERC721Metadata,
 	ERC721Enumerable,
 	ERC721UniqueExtensions,
-	ERC721Mintable,
+	ERC721UniqueMintable,
 	ERC721Burnable,
+	ERC721Metadata,
 	Collection,
 	TokenProperties
 {}
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -25,14 +25,16 @@
 	dispatch::CollectionDispatch,
 	erc::{
 		CollectionHelpersEvents,
-		static_property::{key, value as property_value},
+		static_property::{key},
 	},
+	Pallet as PalletCommon,
 };
 use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};
 use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
+use sp_std::vec;
 use up_data_structs::{
 	CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,
-	CollectionMode, PropertyValue,
+	CollectionMode, PropertyValue, CollectionFlags,
 };
 
 use crate::{Config, SelfWeightOf, weights::WeightInfo};
@@ -57,13 +59,11 @@
 	name: string,
 	description: string,
 	token_prefix: string,
-	base_uri: string,
 ) -> Result<(
 	T::CrossAccountId,
 	CollectionName,
 	CollectionDescription,
 	CollectionTokenPrefix,
-	PropertyValue,
 )> {
 	let caller = T::CrossAccountId::from_eth(caller);
 	let name = name
@@ -81,75 +81,7 @@
 	let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {
 		error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())
 	})?;
-	let base_uri_value = base_uri
-		.into_bytes()
-		.try_into()
-		.map_err(|_| error_field_too_long(stringify!(token_prefix), PropertyValue::bound()))?;
-	Ok((caller, name, description, token_prefix, base_uri_value))
-}
-
-fn make_data<T: Config>(
-	name: CollectionName,
-	mode: CollectionMode,
-	description: CollectionDescription,
-	token_prefix: CollectionTokenPrefix,
-	base_uri_value: PropertyValue,
-	add_properties: bool,
-) -> Result<CreateCollectionData<T::AccountId>> {
-	let mut properties = up_data_structs::CollectionPropertiesVec::default();
-	let mut token_property_permissions =
-		up_data_structs::CollectionPropertiesPermissionsVec::default();
-
-	token_property_permissions
-		.try_push(up_data_structs::PropertyKeyPermission {
-			key: key::url(),
-			permission: up_data_structs::PropertyPermission {
-				mutable: false,
-				collection_admin: true,
-				token_owner: false,
-			},
-		})
-		.map_err(|e| Error::Revert(format!("{:?}", e)))?;
-
-	if add_properties {
-		token_property_permissions
-			.try_push(up_data_structs::PropertyKeyPermission {
-				key: key::suffix(),
-				permission: up_data_structs::PropertyPermission {
-					mutable: false,
-					collection_admin: true,
-					token_owner: false,
-				},
-			})
-			.map_err(|e| Error::Revert(format!("{:?}", e)))?;
-
-		properties
-			.try_push(up_data_structs::Property {
-				key: key::schema_name(),
-				value: property_value::erc721(),
-			})
-			.map_err(|e| Error::Revert(format!("{:?}", e)))?;
-
-		if !base_uri_value.is_empty() {
-			properties
-				.try_push(up_data_structs::Property {
-					key: key::base_uri(),
-					value: base_uri_value,
-				})
-				.map_err(|e| Error::Revert(format!("{:?}", e)))?;
-		}
-	}
-
-	let data = CreateCollectionData {
-		name,
-		mode,
-		description,
-		token_prefix,
-		token_property_permissions,
-		properties,
-		..Default::default()
-	};
-	Ok(data)
+	Ok((caller, name, description, token_prefix))
 }
 
 fn create_refungible_collection_internal<
@@ -160,26 +92,27 @@
 	name: string,
 	description: string,
 	token_prefix: string,
-	base_uri: string,
-	add_properties: bool,
 ) -> Result<address> {
-	let (caller, name, description, token_prefix, base_uri_value) =
-		convert_data::<T>(caller, name, description, token_prefix, base_uri)?;
-	let data = make_data::<T>(
+	let (caller, name, description, token_prefix) =
+		convert_data::<T>(caller, name, description, token_prefix)?;
+	let data = CreateCollectionData {
 		name,
-		CollectionMode::ReFungible,
+		mode: CollectionMode::ReFungible,
 		description,
 		token_prefix,
-		base_uri_value,
-		add_properties,
-	)?;
+		..Default::default()
+	};
 	check_sent_amount_equals_collection_creation_price::<T>(value)?;
 	let collection_helpers_address =
 		T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());
 
-	let collection_id =
-		T::CollectionDispatch::create(caller.clone(), collection_helpers_address, data)
-			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
+	let collection_id = T::CollectionDispatch::create(
+		caller.clone(),
+		collection_helpers_address,
+		data,
+		Default::default(),
+	)
+	.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
 	let address = pallet_common::eth::collection_id_to_address(collection_id);
 	Ok(address)
 }
@@ -212,7 +145,8 @@
 	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
 	/// @return address Address of the newly created collection
 	#[weight(<SelfWeightOf<T>>::create_collection())]
-	fn create_nonfungible_collection(
+	#[solidity(rename_selector = "createNFTCollection")]
+	fn create_nft_collection(
 		&mut self,
 		caller: caller,
 		value: value,
@@ -220,60 +154,51 @@
 		description: string,
 		token_prefix: string,
 	) -> Result<address> {
-		let (caller, name, description, token_prefix, _base_uri_value) =
-			convert_data::<T>(caller, name, description, token_prefix, "".into())?;
-		let data = make_data::<T>(
+		let (caller, name, description, token_prefix) =
+			convert_data::<T>(caller, name, description, token_prefix)?;
+		let data = CreateCollectionData {
 			name,
-			CollectionMode::NFT,
+			mode: CollectionMode::NFT,
 			description,
 			token_prefix,
-			Default::default(),
-			false,
-		)?;
+			..Default::default()
+		};
 		check_sent_amount_equals_collection_creation_price::<T>(value)?;
 		let collection_helpers_address =
 			T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());
-		let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)
-			.map_err(dispatch_to_evm::<T>)?;
+		let collection_id = T::CollectionDispatch::create(
+			caller,
+			collection_helpers_address,
+			data,
+			Default::default(),
+		)
+		.map_err(dispatch_to_evm::<T>)?;
 
 		let address = pallet_common::eth::collection_id_to_address(collection_id);
 		Ok(address)
 	}
-
+	/// Create an NFT collection
+	/// @param name Name of the collection
+	/// @param description Informative description of the collection
+	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
+	/// @return address Address of the newly created collection
 	#[weight(<SelfWeightOf<T>>::create_collection())]
-	#[solidity(rename_selector = "createERC721MetadataCompatibleCollection")]
-	fn create_nonfungible_collection_with_properties(
+	#[deprecated(note = "mathod was renamed to `create_nft_collection`, prefer it instead")]
+	#[solidity(hide)]
+	fn create_nonfungible_collection(
 		&mut self,
 		caller: caller,
 		value: value,
 		name: string,
 		description: string,
 		token_prefix: string,
-		base_uri: string,
 	) -> Result<address> {
-		let (caller, name, description, token_prefix, base_uri_value) =
-			convert_data::<T>(caller, name, description, token_prefix, base_uri)?;
-		let data = make_data::<T>(
-			name,
-			CollectionMode::NFT,
-			description,
-			token_prefix,
-			base_uri_value,
-			true,
-		)?;
-		check_sent_amount_equals_collection_creation_price::<T>(value)?;
-		let collection_helpers_address =
-			T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());
-		let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)
-			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
-
-		let address = pallet_common::eth::collection_id_to_address(collection_id);
-		Ok(address)
+		self.create_nft_collection(caller, value, name, description, token_prefix)
 	}
 
 	#[weight(<SelfWeightOf<T>>::create_collection())]
 	#[solidity(rename_selector = "createRFTCollection")]
-	fn create_refungible_collection(
+	fn create_rft_collection(
 		&mut self,
 		caller: caller,
 		value: value,
@@ -281,37 +206,94 @@
 		description: string,
 		token_prefix: string,
 	) -> Result<address> {
-		create_refungible_collection_internal::<T>(
-			caller,
-			value,
-			name,
-			description,
-			token_prefix,
-			Default::default(),
-			false,
-		)
+		create_refungible_collection_internal::<T>(caller, value, name, description, token_prefix)
 	}
 
-	#[weight(<SelfWeightOf<T>>::create_collection())]
-	#[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]
-	fn create_refungible_collection_with_properties(
+	#[solidity(rename_selector = "makeCollectionERC721MetadataCompatible")]
+	fn make_collection_metadata_compatible(
 		&mut self,
 		caller: caller,
-		value: value,
-		name: string,
-		description: string,
-		token_prefix: string,
+		collection: address,
 		base_uri: string,
-	) -> Result<address> {
-		create_refungible_collection_internal::<T>(
-			caller,
-			value,
-			name,
-			description,
-			token_prefix,
-			base_uri,
-			true,
-		)
+	) -> Result<()> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let collection =
+			pallet_common::eth::map_eth_to_id(&collection).ok_or("not a collection address")?;
+		let mut collection =
+			<crate::CollectionHandle<T>>::new(collection).ok_or("collection not found")?;
+
+		if !matches!(
+			collection.mode,
+			CollectionMode::NFT | CollectionMode::ReFungible
+		) {
+			return Err("target collection should be either NFT or Refungible".into());
+		}
+
+		self.recorder().consume_sstore()?;
+		collection
+			.check_is_owner_or_admin(&caller)
+			.map_err(dispatch_to_evm::<T>)?;
+
+		if collection.flags.erc721metadata {
+			return Err("target collection is already Erc721Metadata compatible".into());
+		}
+		collection.flags.erc721metadata = true;
+
+		let all_permissions = <pallet_common::CollectionPropertyPermissions<T>>::get(collection.id);
+		if all_permissions.get(&key::url()).is_none() {
+			self.recorder().consume_sstore()?;
+			<PalletCommon<T>>::set_property_permission(
+				&collection,
+				&caller,
+				up_data_structs::PropertyKeyPermission {
+					key: key::url(),
+					permission: up_data_structs::PropertyPermission {
+						mutable: true,
+						collection_admin: true,
+						token_owner: false,
+					},
+				},
+			)
+			.map_err(dispatch_to_evm::<T>)?;
+		}
+		if all_permissions.get(&key::suffix()).is_none() {
+			self.recorder().consume_sstore()?;
+			<PalletCommon<T>>::set_property_permission(
+				&collection,
+				&caller,
+				up_data_structs::PropertyKeyPermission {
+					key: key::suffix(),
+					permission: up_data_structs::PropertyPermission {
+						mutable: true,
+						collection_admin: true,
+						token_owner: false,
+					},
+				},
+			)
+			.map_err(dispatch_to_evm::<T>)?;
+		}
+
+		let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);
+		if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {
+			self.recorder().consume_sstore()?;
+			<PalletCommon<T>>::set_collection_properties(
+				&collection,
+				&caller,
+				vec![up_data_structs::Property {
+					key: key::base_uri(),
+					value: base_uri
+						.into_bytes()
+						.try_into()
+						.map_err(|_| "base uri is too large")?,
+				}],
+			)
+			.map_err(dispatch_to_evm::<T>)?;
+		}
+
+		self.recorder().consume_sstore()?;
+		collection.save().map_err(dispatch_to_evm::<T>)?;
+
+		Ok(())
 	}
 
 	/// Check if a collection exists
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -23,16 +23,16 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x5ad4f440
+/// @dev the ERC-165 identifier for this interface is 0x58918631
 contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
 	/// @param description Informative description of the collection
 	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
 	/// @return address Address of the newly created collection
-	/// @dev EVM selector for this function is: 0xe34a6844,
-	///  or in textual repr: createNonfungibleCollection(string,string,string)
-	function createNonfungibleCollection(
+	/// @dev EVM selector for this function is: 0x844af658,
+	///  or in textual repr: createNFTCollection(string,string,string)
+	function createNFTCollection(
 		string memory name,
 		string memory description,
 		string memory tokenPrefix
@@ -45,22 +45,21 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
-	/// @dev EVM selector for this function is: 0xa634a5f9,
-	///  or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string)
-	function createERC721MetadataCompatibleCollection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix,
-		string memory baseUri
-	) public payable returns (address) {
-		require(false, stub_error);
-		name;
-		description;
-		tokenPrefix;
-		baseUri;
-		dummy = 0;
-		return 0x0000000000000000000000000000000000000000;
-	}
+	// /// Create an NFT collection
+	// /// @param name Name of the collection
+	// /// @param description Informative description of the collection
+	// /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
+	// /// @return address Address of the newly created collection
+	// /// @dev EVM selector for this function is: 0xe34a6844,
+	// ///  or in textual repr: createNonfungibleCollection(string,string,string)
+	// function createNonfungibleCollection(string memory name, string memory description, string memory tokenPrefix) public payable returns (address) {
+	// 	require(false, stub_error);
+	// 	name;
+	// 	description;
+	// 	tokenPrefix;
+	// 	dummy = 0;
+	// 	return 0x0000000000000000000000000000000000000000;
+	// }
 
 	/// @dev EVM selector for this function is: 0xab173450,
 	///  or in textual repr: createRFTCollection(string,string,string)
@@ -77,21 +76,13 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
-	/// @dev EVM selector for this function is: 0xa5596388,
-	///  or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
-	function createERC721MetadataCompatibleRFTCollection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix,
-		string memory baseUri
-	) public payable returns (address) {
+	/// @dev EVM selector for this function is: 0x85624258,
+	///  or in textual repr: makeCollectionERC721MetadataCompatible(address,string)
+	function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) public {
 		require(false, stub_error);
-		name;
-		description;
-		tokenPrefix;
+		collection;
 		baseUri;
 		dummy = 0;
-		return 0x0000000000000000000000000000000000000000;
 	}
 
 	/// Check if a collection exists
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -345,7 +345,7 @@
 
 			// =========
 			let sender = T::CrossAccountId::from_sub(sender);
-			let _id = T::CollectionDispatch::create(sender.clone(), sender, data)?;
+			let _id = T::CollectionDispatch::create(sender.clone(), sender, data, Default::default())?;
 
 			Ok(())
 		}
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -365,11 +365,14 @@
 	/// Tokens in foreign collections can be transferred, but not burnt
 	#[bondrewd(bits = "0..1")]
 	pub foreign: bool,
+	/// Supports ERC721Metadata
+	#[bondrewd(bits = "1..2")]
+	pub erc721metadata: bool,
 	/// External collections can't be managed using `unique` api
 	#[bondrewd(bits = "7..8")]
 	pub external: bool,
 
-	#[bondrewd(reserve, bits = "1..7")]
+	#[bondrewd(reserve, bits = "2..7")]
 	pub reserved: u8,
 }
 bondrewd_codec!(CollectionFlags);
@@ -434,6 +437,15 @@
 	pub meta_update_permission: MetaUpdatePermission,
 }
 
+#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+pub struct RpcCollectionFlags {
+	/// Is collection is foreign.
+	pub foreign: bool,
+	/// Collection supports ERC721Metadata.
+	pub erc721metadata: bool,
+}
+
 /// Collection parameters, used in RPC calls (see [`Collection`] for the storage version).
 #[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
 #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
@@ -471,8 +483,8 @@
 	/// Is collection read only.
 	pub read_only: bool,
 
-	/// Is collection is foreign.
-	pub foreign: bool,
+	/// Extra collection flags
+	pub flags: RpcCollectionFlags,
 }
 
 /// Data used for create collection.
modifiedruntime/common/dispatch.rsdiffbeforeafterboth
--- a/runtime/common/dispatch.rs
+++ b/runtime/common/dispatch.rs
@@ -31,7 +31,7 @@
 };
 use up_data_structs::{
 	CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,
-	CollectionId,
+	CollectionId, CollectionFlags,
 };
 
 #[cfg(not(feature = "refungible"))]
@@ -57,10 +57,11 @@
 		sender: T::CrossAccountId,
 		payer: T::CrossAccountId,
 		data: CreateCollectionData<T::AccountId>,
+		flags: CollectionFlags,
 	) -> Result<CollectionId, DispatchError> {
 		let id = match data.mode {
 			CollectionMode::NFT => {
-				<PalletNonfungible<T>>::init_collection(sender, payer, data, false)?
+				<PalletNonfungible<T>>::init_collection(sender, payer, data, flags)?
 			}
 			CollectionMode::Fungible(decimal_points) => {
 				// check params
@@ -68,11 +69,13 @@
 					decimal_points <= MAX_DECIMAL_POINTS,
 					pallet_unique::Error::<T>::CollectionDecimalPointLimitExceeded
 				);
-				<PalletFungible<T>>::init_collection(sender, payer, data)?
+				<PalletFungible<T>>::init_collection(sender, payer, data, flags)?
 			}
 
 			#[cfg(feature = "refungible")]
-			CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, payer, data)?,
+			CollectionMode::ReFungible => {
+				<PalletRefungible<T>>::init_collection(sender, payer, data, flags)?
+			}
 
 			#[cfg(not(feature = "refungible"))]
 			CollectionMode::ReFungible => return unsupported!(T),
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -24,7 +24,7 @@
 use pallet_nonfungible::{
 	Config as NonfungibleConfig,
 	erc::{
-		UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
+		UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, ERC721Call,
 		TokenPropertiesCall,
 	},
 };
@@ -82,18 +82,17 @@
 						let token_id: TokenId = token_id.try_into().ok()?;
 						withdraw_transfer::<T>(&collection, &who, &token_id).map(|()| sponsor)
 					}
-					UniqueNFTCall::ERC721Mintable(
-						ERC721MintableCall::Mint { token_id, .. }
-						| ERC721MintableCall::MintWithTokenUri { token_id, .. },
-					) => {
-						let _token_id: TokenId = token_id.try_into().ok()?;
-						withdraw_create_item::<T>(
-							&collection,
-							&who,
-							&CreateItemData::NFT(CreateNftData::default()),
-						)
-						.map(|()| sponsor)
-					}
+					UniqueNFTCall::ERC721UniqueMintable(
+						ERC721UniqueMintableCall::Mint { .. }
+						| ERC721UniqueMintableCall::MintCheckId { .. }
+						| ERC721UniqueMintableCall::MintWithTokenUri { .. }
+						| ERC721UniqueMintableCall::MintWithTokenUriCheckId { .. },
+					) => withdraw_create_item::<T>(
+						&collection,
+						&who,
+						&CreateItemData::NFT(CreateNftData::default()),
+					)
+					.map(|()| sponsor),
 					UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, from, .. }) => {
 						let token_id: TokenId = token_id.try_into().ok()?;
 						let from = T::CrossAccountId::from_eth(from);
modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
--- a/tests/src/eth/allowlist.test.ts
+++ b/tests/src/eth/allowlist.test.ts
@@ -78,7 +78,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const user = helper.eth.createAccount();
 
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
@@ -94,7 +94,7 @@
   //   const owner = await helper.eth.createAccountWithBalance(donor);
   //   const user = donor;
 
-  //   const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+  //   const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
   //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
   //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
@@ -110,7 +110,7 @@
     const notOwner = await helper.eth.createAccountWithBalance(donor);
     const user = helper.eth.createAccount();
 
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
@@ -129,7 +129,7 @@
   //   const notOwner = await helper.eth.createAccountWithBalance(donor);
   //   const user = donor;
 
-  //   const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+  //   const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
   //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
   //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -18,29 +18,29 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x5ad4f440
+/// @dev the ERC-165 identifier for this interface is 0x58918631
 interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
 	/// @param description Informative description of the collection
 	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
 	/// @return address Address of the newly created collection
-	/// @dev EVM selector for this function is: 0xe34a6844,
-	///  or in textual repr: createNonfungibleCollection(string,string,string)
-	function createNonfungibleCollection(
+	/// @dev EVM selector for this function is: 0x844af658,
+	///  or in textual repr: createNFTCollection(string,string,string)
+	function createNFTCollection(
 		string memory name,
 		string memory description,
 		string memory tokenPrefix
 	) external payable returns (address);
 
-	/// @dev EVM selector for this function is: 0xa634a5f9,
-	///  or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string)
-	function createERC721MetadataCompatibleCollection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix,
-		string memory baseUri
-	) external payable returns (address);
+	// /// Create an NFT collection
+	// /// @param name Name of the collection
+	// /// @param description Informative description of the collection
+	// /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications
+	// /// @return address Address of the newly created collection
+	// /// @dev EVM selector for this function is: 0xe34a6844,
+	// ///  or in textual repr: createNonfungibleCollection(string,string,string)
+	// function createNonfungibleCollection(string memory name, string memory description, string memory tokenPrefix) external payable returns (address);
 
 	/// @dev EVM selector for this function is: 0xab173450,
 	///  or in textual repr: createRFTCollection(string,string,string)
@@ -50,14 +50,9 @@
 		string memory tokenPrefix
 	) external payable returns (address);
 
-	/// @dev EVM selector for this function is: 0xa5596388,
-	///  or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
-	function createERC721MetadataCompatibleRFTCollection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix,
-		string memory baseUri
-	) external payable returns (address);
+	/// @dev EVM selector for this function is: 0x85624258,
+	///  or in textual repr: makeCollectionERC721MetadataCompatible(address,string)
+	function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) external;
 
 	/// Check if a collection exists
 	/// @param collectionAddress Address of the collection in question
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -194,9 +194,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) external;
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) external;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x63034ac5
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -62,7 +62,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -243,9 +243,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) external;
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) external;
 }
 
 /// @dev anonymous struct
@@ -254,6 +254,36 @@
 	uint256 field_1;
 }
 
+/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
+/// @dev See https://eips.ethereum.org/EIPS/eip-721
+/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
+interface ERC721Metadata is Dummy, ERC165 {
+	// /// @notice A descriptive name for a collection of NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x06fdde03,
+	// ///  or in textual repr: name()
+	// function name() external view returns (string memory);
+
+	// /// @notice An abbreviated name for NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x95d89b41,
+	// ///  or in textual repr: symbol()
+	// function symbol() external view returns (string memory);
+
+	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+	///
+	/// @dev If the token has a `url` property and it is not empty, it is returned.
+	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
+	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
+	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+	///
+	/// @return token's const_metadata
+	/// @dev EVM selector for this function is: 0xc87b56dd,
+	///  or in textual repr: tokenURI(uint256)
+	function tokenURI(uint256 tokenId) external view returns (string memory);
+}
+
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 interface ERC721Burnable is Dummy, ERC165 {
@@ -267,39 +297,50 @@
 }
 
 /// @dev inlined interface
-interface ERC721MintableEvents {
+interface ERC721UniqueMintableEvents {
 	event MintingFinished();
 }
 
 /// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x68ccfe89
-interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
+/// @dev the ERC-165 identifier for this interface is 0x476ff149
+interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
 	/// @dev EVM selector for this function is: 0x05d2035b,
 	///  or in textual repr: mintingFinished()
 	function mintingFinished() external view returns (bool);
 
 	/// @notice Function to mint token.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted NFT
-	/// @dev EVM selector for this function is: 0x40c10f19,
-	///  or in textual repr: mint(address,uint256)
-	function mint(address to, uint256 tokenId) external returns (bool);
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x6a627842,
+	///  or in textual repr: mint(address)
+	function mint(address to) external returns (uint256);
+
+	// /// @notice Function to mint token.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted NFT
+	// /// @dev EVM selector for this function is: 0x40c10f19,
+	// ///  or in textual repr: mint(address,uint256)
+	// function mint(address to, uint256 tokenId) external returns (bool);
 
 	/// @notice Function to mint token with the given tokenUri.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted NFT
 	/// @param tokenUri Token URI that would be stored in the NFT properties
-	/// @dev EVM selector for this function is: 0x50bb4e7f,
-	///  or in textual repr: mintWithTokenURI(address,uint256,string)
-	function mintWithTokenURI(
-		address to,
-		uint256 tokenId,
-		string memory tokenUri
-	) external returns (bool);
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x45c17782,
+	///  or in textual repr: mintWithTokenURI(address,string)
+	function mintWithTokenURI(address to, string memory tokenUri) external returns (uint256);
+
+	// /// @notice Function to mint token with the given tokenUri.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted NFT
+	// /// @param tokenUri Token URI that would be stored in the NFT properties
+	// /// @dev EVM selector for this function is: 0x50bb4e7f,
+	// ///  or in textual repr: mintWithTokenURI(address,uint256,string)
+	// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
 
 	/// @dev Not implemented
 	/// @dev EVM selector for this function is: 0x7d64bcb4,
@@ -308,8 +349,18 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xd74d154f
+/// @dev the ERC-165 identifier for this interface is 0x4468500d
 interface ERC721UniqueExtensions is Dummy, ERC165 {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	/// @dev EVM selector for this function is: 0x06fdde03,
+	///  or in textual repr: name()
+	function name() external view returns (string memory);
+
+	/// @notice An abbreviated name for NFTs in this contract
+	/// @dev EVM selector for this function is: 0x95d89b41,
+	///  or in textual repr: symbol()
+	function symbol() external view returns (string memory);
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -350,11 +401,11 @@
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	/// @dev EVM selector for this function is: 0x36543006,
 	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);
+	function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);
 }
 
 /// @dev anonymous struct
-struct Tuple8 {
+struct Tuple6 {
 	uint256 field_0;
 	string field_1;
 }
@@ -384,34 +435,6 @@
 	function totalSupply() external view returns (uint256);
 }
 
-/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
-/// @dev See https://eips.ethereum.org/EIPS/eip-721
-/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
-interface ERC721Metadata is Dummy, ERC165 {
-	/// @notice A descriptive name for a collection of NFTs in this contract
-	/// @dev EVM selector for this function is: 0x06fdde03,
-	///  or in textual repr: name()
-	function name() external view returns (string memory);
-
-	/// @notice An abbreviated name for NFTs in this contract
-	/// @dev EVM selector for this function is: 0x95d89b41,
-	///  or in textual repr: symbol()
-	function symbol() external view returns (string memory);
-
-	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
-	///
-	/// @dev If the token has a `url` property and it is not empty, it is returned.
-	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
-	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
-	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
-	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
-	///
-	/// @return token's const_metadata
-	/// @dev EVM selector for this function is: 0xc87b56dd,
-	///  or in textual repr: tokenURI(uint256)
-	function tokenURI(uint256 tokenId) external view returns (string memory);
-}
-
 /// @dev inlined interface
 interface ERC721Events {
 	event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
@@ -507,11 +530,11 @@
 	Dummy,
 	ERC165,
 	ERC721,
-	ERC721Metadata,
 	ERC721Enumerable,
 	ERC721UniqueExtensions,
-	ERC721Mintable,
+	ERC721UniqueMintable,
 	ERC721Burnable,
+	ERC721Metadata,
 	Collection,
 	TokenProperties
 {}
deletedtests/src/eth/api/UniqueRFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRFT.sol
+++ /dev/null
@@ -1,163 +0,0 @@
-// SPDX-License-Identifier: OTHER
-// This code is automatically generated
-
-pragma solidity >=0.8.0 <0.9.0;
-
-// Common stubs holder
-interface Dummy {
-
-}
-
-interface ERC165 is Dummy {
-	function supportsInterface(bytes4 interfaceID) external view returns (bool);
-}
-
-// Selector: 7d9262e6
-interface Collection is Dummy, ERC165 {
-	// Set collection property.
-	//
-	// @param key Property key.
-	// @param value Propery value.
-	//
-	// Selector: setCollectionProperty(string,bytes) 2f073f66
-	function setCollectionProperty(string memory key, bytes memory value)
-		external;
-
-	// Delete collection property.
-	//
-	// @param key Property key.
-	//
-	// Selector: deleteCollectionProperty(string) 7b7debce
-	function deleteCollectionProperty(string memory key) external;
-
-	// Get collection property.
-	//
-	// @dev Throws error if key not found.
-	//
-	// @param key Property key.
-	// @return bytes The property corresponding to the key.
-	//
-	// Selector: collectionProperty(string) cf24fd6d
-	function collectionProperty(string memory key)
-		external
-		view
-		returns (bytes memory);
-
-	// Set the sponsor of the collection.
-	//
-	// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
-	//
-	// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
-	//
-	// Selector: setCollectionSponsor(address) 7623402e
-	function setCollectionSponsor(address sponsor) external;
-
-	// Collection sponsorship confirmation.
-	//
-	// @dev After setting the sponsor for the collection, it must be confirmed with this function.
-	//
-	// Selector: confirmCollectionSponsorship() 3c50e97a
-	function confirmCollectionSponsorship() external;
-
-	// Set limits for the collection.
-	// @dev Throws error if limit not found.
-	// @param limit Name of the limit. Valid names:
-	// 	"accountTokenOwnershipLimit",
-	// 	"sponsoredDataSize",
-	// 	"sponsoredDataRateLimit",
-	// 	"tokenLimit",
-	// 	"sponsorTransferTimeout",
-	// 	"sponsorApproveTimeout"
-	// @param value Value of the limit.
-	//
-	// Selector: setCollectionLimit(string,uint32) 6a3841db
-	function setCollectionLimit(string memory limit, uint32 value) external;
-
-	// Set limits for the collection.
-	// @dev Throws error if limit not found.
-	// @param limit Name of the limit. Valid names:
-	// 	"ownerCanTransfer",
-	// 	"ownerCanDestroy",
-	// 	"transfersEnabled"
-	// @param value Value of the limit.
-	//
-	// Selector: setCollectionLimit(string,bool) 993b7fba
-	function setCollectionLimit(string memory limit, bool value) external;
-
-	// Get contract address.
-	//
-	// Selector: contractAddress() f6b4dfb4
-	function contractAddress() external view returns (address);
-
-	// Add collection admin by substrate address.
-	// @param new_admin Substrate administrator address.
-	//
-	// Selector: addCollectionAdminSubstrate(uint256) 5730062b
-	function addCollectionAdminSubstrate(uint256 newAdmin) external;
-
-	// Remove collection admin by substrate address.
-	// @param admin Substrate administrator address.
-	//
-	// Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
-	function removeCollectionAdminSubstrate(uint256 admin) external;
-
-	// Add collection admin.
-	// @param new_admin Address of the added administrator.
-	//
-	// Selector: addCollectionAdmin(address) 92e462c7
-	function addCollectionAdmin(address newAdmin) external;
-
-	// Remove collection admin.
-	//
-	// @param new_admin Address of the removed administrator.
-	//
-	// Selector: removeCollectionAdmin(address) fafd7b42
-	function removeCollectionAdmin(address admin) external;
-
-	// Toggle accessibility of collection nesting.
-	//
-	// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
-	//
-	// Selector: setCollectionNesting(bool) 112d4586
-	function setCollectionNesting(bool enable) external;
-
-	// Toggle accessibility of collection nesting.
-	//
-	// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
-	// @param collections Addresses of collections that will be available for nesting.
-	//
-	// Selector: setCollectionNesting(bool,address[]) 64872396
-	function setCollectionNesting(bool enable, address[] memory collections)
-		external;
-
-	// Set the collection access method.
-	// @param mode Access mode
-	// 	0 for Normal
-	// 	1 for AllowList
-	//
-	// Selector: setCollectionAccess(uint8) 41835d4c
-	function setCollectionAccess(uint8 mode) external;
-
-	// Add the user to the allowed list.
-	//
-	// @param user Address of a trusted user.
-	//
-	// Selector: addToCollectionAllowList(address) 67844fe6
-	function addToCollectionAllowList(address user) external;
-
-	// Remove the user from the allowed list.
-	//
-	// @param user Address of a removed user.
-	//
-	// Selector: removeFromCollectionAllowList(address) 85c51acb
-	function removeFromCollectionAllowList(address user) external;
-
-	// Switch permission for minting.
-	//
-	// @param mode Enable if "true".
-	//
-	// Selector: setCollectionMintMode(bool) 00018e84
-	function setCollectionMintMode(bool mode) external;
-}
-
-interface UniqueRFT is Dummy, ERC165, Collection {}
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -62,7 +62,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3e1e8083
+/// @dev the ERC-165 identifier for this interface is 0x62e22290
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -243,9 +243,9 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner account
-	/// @dev EVM selector for this function is: 0x13af4035,
-	///  or in textual repr: setOwner(address)
-	function setOwner(address newOwner) external;
+	/// @dev EVM selector for this function is: 0x4f53e226,
+	///  or in textual repr: changeCollectionOwner(address)
+	function changeCollectionOwner(address newOwner) external;
 }
 
 /// @dev anonymous struct
@@ -254,6 +254,34 @@
 	uint256 field_1;
 }
 
+/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
+interface ERC721Metadata is Dummy, ERC165 {
+	// /// @notice A descriptive name for a collection of NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x06fdde03,
+	// ///  or in textual repr: name()
+	// function name() external view returns (string memory);
+
+	// /// @notice An abbreviated name for NFTs in this contract
+	// /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	// /// @dev EVM selector for this function is: 0x95d89b41,
+	// ///  or in textual repr: symbol()
+	// function symbol() external view returns (string memory);
+
+	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+	///
+	/// @dev If the token has a `url` property and it is not empty, it is returned.
+	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
+	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
+	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+	///
+	/// @return token's const_metadata
+	/// @dev EVM selector for this function is: 0xc87b56dd,
+	///  or in textual repr: tokenURI(uint256)
+	function tokenURI(uint256 tokenId) external view returns (string memory);
+}
+
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 interface ERC721Burnable is Dummy, ERC165 {
@@ -267,40 +295,51 @@
 }
 
 /// @dev inlined interface
-interface ERC721MintableEvents {
+interface ERC721UniqueMintableEvents {
 	event MintingFinished();
 }
 
 /// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x68ccfe89
-interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
+/// @dev the ERC-165 identifier for this interface is 0x476ff149
+interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
 	/// @dev EVM selector for this function is: 0x05d2035b,
 	///  or in textual repr: mintingFinished()
 	function mintingFinished() external view returns (bool);
 
 	/// @notice Function to mint token.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted RFT
-	/// @dev EVM selector for this function is: 0x40c10f19,
-	///  or in textual repr: mint(address,uint256)
-	function mint(address to, uint256 tokenId) external returns (bool);
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x6a627842,
+	///  or in textual repr: mint(address)
+	function mint(address to) external returns (uint256);
+
+	// /// @notice Function to mint token.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted RFT
+	// /// @dev EVM selector for this function is: 0x40c10f19,
+	// ///  or in textual repr: mint(address,uint256)
+	// function mint(address to, uint256 tokenId) external returns (bool);
 
 	/// @notice Function to mint token with the given tokenUri.
-	/// @dev `tokenId` should be obtained with `nextTokenId` method,
-	///  unlike standard, you can't specify it manually
 	/// @param to The new owner
-	/// @param tokenId ID of the minted RFT
-	/// @param tokenUri Token URI that would be stored in the RFT properties
-	/// @dev EVM selector for this function is: 0x50bb4e7f,
-	///  or in textual repr: mintWithTokenURI(address,uint256,string)
-	function mintWithTokenURI(
-		address to,
-		uint256 tokenId,
-		string memory tokenUri
-	) external returns (bool);
+	/// @param tokenUri Token URI that would be stored in the NFT properties
+	/// @return uint256 The id of the newly minted token
+	/// @dev EVM selector for this function is: 0x45c17782,
+	///  or in textual repr: mintWithTokenURI(address,string)
+	function mintWithTokenURI(address to, string memory tokenUri) external returns (uint256);
 
+	// /// @notice Function to mint token with the given tokenUri.
+	// /// @dev `tokenId` should be obtained with `nextTokenId` method,
+	// ///  unlike standard, you can't specify it manually
+	// /// @param to The new owner
+	// /// @param tokenId ID of the minted RFT
+	// /// @param tokenUri Token URI that would be stored in the RFT properties
+	// /// @dev EVM selector for this function is: 0x50bb4e7f,
+	// ///  or in textual repr: mintWithTokenURI(address,uint256,string)
+	// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
+
 	/// @dev Not implemented
 	/// @dev EVM selector for this function is: 0x7d64bcb4,
 	///  or in textual repr: finishMinting()
@@ -308,8 +347,18 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x7c3bef89
+/// @dev the ERC-165 identifier for this interface is 0xef1eaacb
 interface ERC721UniqueExtensions is Dummy, ERC165 {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	/// @dev EVM selector for this function is: 0x06fdde03,
+	///  or in textual repr: name()
+	function name() external view returns (string memory);
+
+	/// @notice An abbreviated name for NFTs in this contract
+	/// @dev EVM selector for this function is: 0x95d89b41,
+	///  or in textual repr: symbol()
+	function symbol() external view returns (string memory);
+
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
@@ -352,7 +401,7 @@
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	/// @dev EVM selector for this function is: 0x36543006,
 	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);
+	function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);
 
 	/// Returns EVM address for refungible token
 	///
@@ -363,7 +412,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple8 {
+struct Tuple6 {
 	uint256 field_0;
 	string field_1;
 }
@@ -393,32 +442,6 @@
 	function totalSupply() external view returns (uint256);
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
-interface ERC721Metadata is Dummy, ERC165 {
-	/// @notice A descriptive name for a collection of RFTs in this contract
-	/// @dev EVM selector for this function is: 0x06fdde03,
-	///  or in textual repr: name()
-	function name() external view returns (string memory);
-
-	/// @notice An abbreviated name for RFTs in this contract
-	/// @dev EVM selector for this function is: 0x95d89b41,
-	///  or in textual repr: symbol()
-	function symbol() external view returns (string memory);
-
-	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
-	///
-	/// @dev If the token has a `url` property and it is not empty, it is returned.
-	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.
-	///  If the collection property `baseURI` is empty or absent, return "" (empty string)
-	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
-	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
-	///
-	/// @return token's const_metadata
-	/// @dev EVM selector for this function is: 0xc87b56dd,
-	///  or in textual repr: tokenURI(uint256)
-	function tokenURI(uint256 tokenId) external view returns (string memory);
-}
-
 /// @dev inlined interface
 interface ERC721Events {
 	event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
@@ -512,11 +535,11 @@
 	Dummy,
 	ERC165,
 	ERC721,
-	ERC721Metadata,
 	ERC721Enumerable,
 	ERC721UniqueExtensions,
-	ERC721Mintable,
+	ERC721UniqueMintable,
 	ERC721Burnable,
+	ERC721Metadata,
 	Collection,
 	TokenProperties
 {}
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -23,7 +23,7 @@
 describe('Contract calls', () => {
   let donor: IKeyringPair;
 
-  before(async function() {
+  before(async function () {
     await usingEthPlaygrounds(async (_helper, privateKey) => {
       donor = await privateKey({filename: __filename});
     });
@@ -40,7 +40,12 @@
   itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {
     const userA = await helper.eth.createAccountWithBalance(donor);
     const userB = helper.eth.createAccount();
-    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({from: userA, to: userB, value: '1000000', gas: helper.eth.DEFAULT_GAS}));
+    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({
+      from: userA,
+      to: userB,
+      value: '1000000',
+      gas: helper.eth.DEFAULT_GAS
+    }));
     const balanceB = await helper.balance.getEthereum(userB);
     expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;
   });
@@ -69,51 +74,59 @@
 describe('ERC165 tests', async () => {
   // https://eips.ethereum.org/EIPS/eip-165
 
-  let collection: number;
+  let erc721MetadataCompatibleNftCollectionId: number;
+  let simpleNftCollectionId: number;
   let minter: string;
 
-  function contract(helper: EthUniqueHelper): Contract {
-    return helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection), 'nft', minter);
+  const BASE_URI = 'base/';
+
+  async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {
+    const simple = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);
+    const compatible = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);
+
+    expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);
+    expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);
   }
 
   before(async () => {
     await usingEthPlaygrounds(async (helper, privateKey) => {
       const donor = await privateKey({filename: __filename});
       const [alice] = await helper.arrange.createAccounts([10n], donor);
-      ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
+      ({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
       minter = helper.eth.createAccount();
+      ({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));
     });
   });
 
-  itEth('interfaceID == 0xffffffff always false', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0xffffffff').call()).to.be.false;
+  itEth('nonexistent interfaceID - 0xffffffff - always false', async ({helper}) => {
+    await checkInterface(helper, '0xffffffff', false, false);
   });
 
-  itEth('ERC721 support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;
+  itEth('ERC721 - 0x780e9d63 - support', async ({helper}) => {
+    await checkInterface(helper, '0x780e9d63', true, true);
   });
 
-  itEth('ERC721Metadata support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x5b5e139f').call()).to.be.true;
+  itEth('ERC721Metadata - 0x5b5e139f - support', async ({helper}) => {
+    await checkInterface(helper, '0x5b5e139f', false, true);
   });
 
-  itEth('ERC721Mintable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x68ccfe89').call()).to.be.true;
+  itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {
+    await checkInterface(helper, '0x476ff149', true, true);
   });
 
-  itEth('ERC721Enumerable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;
+  itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {
+    await checkInterface(helper, '0x780e9d63', true, true);
   });
 
-  itEth('ERC721UniqueExtensions support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0xd74d154f').call()).to.be.true;
+  itEth('ERC721UniqueExtensions - 0x4468500d - support', async ({helper}) => {
+    await checkInterface(helper, '0x4468500d', true, true);
   });
 
-  itEth('ERC721Burnable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x42966c68').call()).to.be.true;
+  itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {
+    await checkInterface(helper, '0x42966c68', true, true);
   });
 
-  itEth('ERC165 support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x01ffc9a7').call()).to.be.true;
+  itEth('ERC165 - 0x01ffc9a7 - support', async ({helper}) => {
+    await checkInterface(helper, '0x01ffc9a7', true, true);
   });
 });
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -38,7 +38,7 @@
 
   itEth('Add admin by owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     const newAdmin = helper.eth.createAccount();
@@ -51,7 +51,7 @@
 
   itEth.skip('Add substrate admin by owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     const [newAdmin] = await helper.arrange.createAccounts([10n], donor);
@@ -64,7 +64,7 @@
 
   itEth('Verify owner or admin', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const newAdmin = helper.eth.createAccount();
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -75,7 +75,7 @@
 
   itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const admin = await helper.eth.createAccountWithBalance(donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -93,7 +93,7 @@
 
   itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const notAdmin = await helper.eth.createAccountWithBalance(donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -108,7 +108,7 @@
 
   itEth.skip('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const admin = await helper.eth.createAccountWithBalance(donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -126,7 +126,7 @@
 
   itEth.skip('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const notAdmin0 = await helper.eth.createAccountWithBalance(donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -150,7 +150,7 @@
 
   itEth('Remove admin by owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const newAdmin = helper.eth.createAccount();
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -170,7 +170,7 @@
 
   itEth.skip('Remove substrate admin by owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const [newAdmin] = await helper.arrange.createAccounts([10n], donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -188,7 +188,7 @@
 
   itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
@@ -210,7 +210,7 @@
 
   itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
@@ -230,7 +230,7 @@
 
   itEth.skip('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const [adminSub] = await helper.arrange.createAccounts([10n], donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -250,7 +250,7 @@
 
   itEth.skip('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
     const [adminSub] = await helper.arrange.createAccounts([10n], donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
@@ -279,10 +279,10 @@
   itEth('Change owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const newOwner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    await collectionEvm.methods.setOwner(newOwner).send();
+    await collectionEvm.methods.changeCollectionOwner(newOwner).send();
 
     expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;
     expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;
@@ -291,9 +291,9 @@
   itEth('change owner call fee', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const newOwner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwner(newOwner).send());
+    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
     expect(cost > 0);
   });
@@ -301,10 +301,10 @@
   itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const newOwner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    await expect(collectionEvm.methods.setOwner(newOwner).send({from: newOwner})).to.be.rejected;
+    await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;
     expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;
   });
 });
@@ -321,7 +321,7 @@
   itEth.skip('Change owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const [newOwner] = await helper.arrange.createAccounts([10n], donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;
@@ -336,7 +336,7 @@
   itEth.skip('change owner call fee', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const [newOwner] = await helper.arrange.createAccounts([10n], donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());
@@ -348,7 +348,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const otherReceiver = await helper.eth.createAccountWithBalance(donor);
     const [newOwner] = await helper.arrange.createAccounts([10n], donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
     await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -29,33 +29,9 @@
     "inputs": [
       { "internalType": "string", "name": "name", "type": "string" },
       { "internalType": "string", "name": "description", "type": "string" },
-      { "internalType": "string", "name": "tokenPrefix", "type": "string" },
-      { "internalType": "string", "name": "baseUri", "type": "string" }
-    ],
-    "name": "createERC721MetadataCompatibleCollection",
-    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
-    "stateMutability": "payable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "string", "name": "name", "type": "string" },
-      { "internalType": "string", "name": "description", "type": "string" },
-      { "internalType": "string", "name": "tokenPrefix", "type": "string" },
-      { "internalType": "string", "name": "baseUri", "type": "string" }
-    ],
-    "name": "createERC721MetadataCompatibleRFTCollection",
-    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
-    "stateMutability": "payable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "string", "name": "name", "type": "string" },
-      { "internalType": "string", "name": "description", "type": "string" },
       { "internalType": "string", "name": "tokenPrefix", "type": "string" }
     ],
-    "name": "createNonfungibleCollection",
+    "name": "createNFTCollection",
     "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
     "stateMutability": "payable",
     "type": "function"
@@ -86,6 +62,16 @@
   },
   {
     "inputs": [
+      { "internalType": "address", "name": "collection", "type": "address" },
+      { "internalType": "string", "name": "baseUri", "type": "string" }
+    ],
+    "name": "makeCollectionERC721MetadataCompatible",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
     ],
     "name": "supportsInterface",
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -14,8 +14,11 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {itEth, usingEthPlaygrounds, expect} from './util';
+import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
+import {Pallets} from '../util';
+import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
 import {IKeyringPair} from '@polkadot/types/types';
+import {Contract} from 'web3-eth-contract';
 
 describe('EVM collection properties', () => {
   let donor: IKeyringPair;
@@ -30,7 +33,7 @@
 
   itEth('Can be set', async({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test'});
+    const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
     await collection.addAdmin(alice, {Ethereum: caller});
 
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
@@ -70,3 +73,92 @@
     expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));
   });
 });
+
+describe('Supports ERC721Metadata', () => {
+  let donor: IKeyringPair;
+
+  before(async function() {
+    await usingEthPlaygrounds(async (_helper, privateKey) => {
+      donor = await privateKey({filename: __filename});
+    });
+  });
+
+  const checkERC721Metadata = async (helper: EthUniqueHelper, mode: 'nft' | 'rft') => {
+    const caller = await helper.eth.createAccountWithBalance(donor);
+    const bruh = await helper.eth.createAccountWithBalance(donor);
+
+    const BASE_URI = 'base/'
+    const SUFFIX = 'suffix1'
+    const URI = 'uri1'
+
+    const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);
+    const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection'
+
+    const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p')
+
+    const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);
+    await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too
+
+    const collection1 = await helper.nft.getCollectionObject(collectionId);
+    const data1 = await collection1.getData()
+    expect(data1?.raw.flags.erc721metadata).to.be.false;
+    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;
+
+    await collectionHelpers.methods.makeCollectionERC721MetadataCompatible(collectionAddress, BASE_URI)
+      .send({from: bruh});
+
+    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
+
+    const collection2 = await helper.nft.getCollectionObject(collectionId);
+    const data2 = await collection2.getData()
+    expect(data2?.raw.flags.erc721metadata).to.be.true;
+
+    const TPPs = data2?.raw.tokenPropertyPermissions
+    expect(TPPs?.length).to.equal(2);
+
+    expect(TPPs.find((tpp: ITokenPropertyPermission) => {
+      return tpp.key === "URI" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
+    })).to.be.not.null
+
+    expect(TPPs.find((tpp: ITokenPropertyPermission) => {
+      return tpp.key === "URISuffix" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
+    })).to.be.not.null
+
+    expect(data2?.raw.properties?.find((property: IProperty) => {
+      return property.key === "baseURI" && property.value === BASE_URI
+    })).to.be.not.null
+
+    const token1Result = await contract.methods.mint(bruh).send();
+    const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
+
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);
+
+    await contract.methods.setProperty(tokenId1, "URISuffix", Buffer.from(SUFFIX)).send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
+
+    await contract.methods.setProperty(tokenId1, "URI", Buffer.from(URI)).send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
+
+    await contract.methods.deleteProperty(tokenId1, "URI").send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
+
+    const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();
+    const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;
+
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
+
+    await contract.methods.deleteProperty(tokenId2, "URI").send();
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
+
+    await contract.methods.setProperty(tokenId2, "URISuffix", Buffer.from(SUFFIX)).send();
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
+  }
+
+  itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
+    await checkERC721Metadata(helper, 'nft');
+  });
+
+  itEth.ifWithPallets('ERC721Metadata property can be set for RFT collection', [Pallets.ReFungible], async({helper}) => {
+    await checkERC721Metadata(helper, 'rft');
+  });
+});
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -44,9 +44,8 @@
 
     await collection.addToAllowList(alice, {Ethereum: minter});
 
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.equal('1');
-    const result = await contract.methods.mint(minter, nextTokenId).send();
+    const result = await contract.methods.mint(minter).send();
+
     const events = helper.eth.normalizeEvents(result.events);
     expect(events).to.be.deep.equal([
       {
@@ -55,7 +54,7 @@
         args: {
           from: '0x0000000000000000000000000000000000000000',
           to: minter,
-          tokenId: nextTokenId,
+          tokenId: '1',
         },
       },
     ]);
@@ -65,7 +64,7 @@
   // itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {
   //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
   //   const collectionHelpers = evmCollectionHelpers(web3, owner);
-  //   let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+  //   let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send();
   //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
   //   const sponsor = privateKeyWrapper('//Alice');
   //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -73,11 +72,11 @@
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
   //   result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
-    
+
   //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
   //   await submitTransactionAsync(sponsor, confirmTx);
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
-    
+
   //   const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
   //   expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);
   // });
@@ -86,7 +85,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
+    let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
     const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
@@ -94,28 +93,26 @@
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
-    
+
     await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
-    
+
     await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
-    
+
     const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
     expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
   });
 
   itEth('Sponsoring collection from evm address via access list', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
-    const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
+    const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
+
     const collection = helper.nft.getCollectionObject(collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
-    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
+    await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
     let collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
@@ -144,23 +141,17 @@
     const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
 
     {
-      const nextTokenId = await collectionEvm.methods.nextTokenId().call();
-      expect(nextTokenId).to.be.equal('1');
-      const result = await collectionEvm.methods.mintWithTokenURI(
-        user,
-        nextTokenId,
-        'Test URI',
-      ).send({from: user});
+      const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
       const events = helper.eth.normalizeEvents(result.events);
 
       expect(events).to.be.deep.equal([
         {
-          address: collectionIdAddress,
+          address: collectionAddress,
           event: 'Transfer',
           args: {
             from: '0x0000000000000000000000000000000000000000',
             to: user,
-            tokenId: nextTokenId,
+            tokenId: '1',
           },
         },
       ]);
@@ -178,16 +169,16 @@
   // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {
   //   const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
   //   const collectionHelpers = evmCollectionHelpers(web3, owner);
-  //   const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+  //   const result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send();
   //   const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
   //   const sponsor = privateKeyWrapper('//Alice');
   //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
 
   //   await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
-    
+
   //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
   //   await submitTransactionAsync(sponsor, confirmTx);
-    
+
   //   const user = createEthAccount(web3);
   //   const nextTokenId = await collectionEvm.methods.nextTokenId().call();
   //   expect(nextTokenId).to.be.equal('1');
@@ -232,39 +223,32 @@
 
   itEth('Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
-    const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
+    const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
     const collection = helper.nft.getCollectionObject(collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
-    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
+    await collectionEvm.methods.setCollectionSponsor(sponsor).send();
     let collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
-    const sponsorCollection = helper.ethNativeContract.collection(collectionIdAddress, 'nft', sponsor);
+    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
 
     const user = helper.eth.createAccount();
     await collectionEvm.methods.addCollectionAdmin(user).send();
-    
+
     const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
     const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
 
-    const userCollectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', user);
-    const nextTokenId = await userCollectionEvm.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    result = await userCollectionEvm.methods.mintWithTokenURI(
-      user,
-      nextTokenId,
-      'Test URI',
-    ).send();
+    const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
+
+    let result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI',).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const events = helper.eth.normalizeEvents(result.events);
     const address = helper.ethAddress.fromCollectionId(collectionId);
@@ -276,12 +260,12 @@
         args: {
           from: '0x0000000000000000000000000000000000000000',
           to: user,
-          tokenId: nextTokenId,
+          tokenId: '1',
         },
       },
     ]);
-    expect(await userCollectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
-  
+    expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
+
     const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
     expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
     const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -35,13 +35,49 @@
     const description = 'Some description';
     const prefix = 'token prefix';
 
-    const {collectionId} = await helper.eth.createNonfungibleCollection(owner, name, description, prefix);
+    const {collectionId} = await helper.eth.createNFTCollection(owner, name, description, prefix);
     const data = (await helper.rft.getData(collectionId))!;
+    const collection = helper.nft.getCollectionObject(collectionId);
+    
+    expect(data.name).to.be.eq(name);
+    expect(data.description).to.be.eq(description);
+    expect(data.raw.tokenPrefix).to.be.eq(prefix);
+    expect(data.raw.mode).to.be.eq('NFT');
+
+    const options = await collection.getOptions();
+
+    expect(options.tokenPropertyPermissions).to.be.empty;
+  });
+
+  itEth('Create collection with properties', async ({helper}) => {
+    const owner = await helper.eth.createAccountWithBalance(donor);
+
+    const name = 'CollectionEVM';
+    const description = 'Some description';
+    const prefix = 'token prefix';
+    const baseUri = 'BaseURI';
+
+    const {collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);
+
+    const collection = helper.nft.getCollectionObject(collectionId);
+    const data = (await collection.getData())!;
     
     expect(data.name).to.be.eq(name);
     expect(data.description).to.be.eq(description);
     expect(data.raw.tokenPrefix).to.be.eq(prefix);
     expect(data.raw.mode).to.be.eq('NFT');
+
+    const options = await collection.getOptions();
+    expect(options.tokenPropertyPermissions).to.be.deep.equal([
+      {
+        key: 'URI',
+        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
+      },
+      {
+        key: 'URISuffix',
+        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
+      },
+    ]);
   });
 
   // this test will occasionally fail when in async environment.
@@ -57,7 +93,7 @@
       .call()).to.be.false;
 
     await collectionHelpers.methods
-      .createNonfungibleCollection('A', 'A', 'A')
+      .createNFTCollection('A', 'A', 'A')
       .send({value: Number(2n * helper.balance.getOneTokenNominal())});
     
     expect(await collectionHelpers.methods
@@ -69,7 +105,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
-    const {collectionId, collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');
+    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');
 
     const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
     await collection.methods.setCollectionSponsor(sponsor).send();
@@ -88,7 +124,7 @@
 
   itEth('Set limits', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Limits', 'absolutely anything', 'FLO');
+    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');
     const limits = {
       accountTokenOwnershipLimit: 1000,
       sponsoredDataSize: 1024,
@@ -131,7 +167,7 @@
       .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())
       .to.be.false;
     
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Exister', 'absolutely anything', 'EVC');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
@@ -159,7 +195,7 @@
       const tokenPrefix = 'A';
 
       await expect(collectionHelper.methods
-        .createNonfungibleCollection(collectionName, description, tokenPrefix)
+        .createNFTCollection(collectionName, description, tokenPrefix)
         .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
       
     }
@@ -169,7 +205,7 @@
       const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);
       const tokenPrefix = 'A';
       await expect(collectionHelper.methods
-        .createNonfungibleCollection(collectionName, description, tokenPrefix)
+        .createNFTCollection(collectionName, description, tokenPrefix)
         .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
     }
     {
@@ -178,7 +214,7 @@
       const description = 'A';
       const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
       await expect(collectionHelper.methods
-        .createNonfungibleCollection(collectionName, description, tokenPrefix)
+        .createNFTCollection(collectionName, description, tokenPrefix)
         .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
     }
   });
@@ -187,14 +223,14 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
     await expect(collectionHelper.methods
-      .createNonfungibleCollection('Peasantry', 'absolutely anything', 'CVE')
+      .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')
       .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
 
   itEth('(!negative test!) Check owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const malfeasant = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Transgressed', 'absolutely anything', 'COR');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');
     const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);
     const EXPECTED_ERROR = 'NoPermission';
     {
@@ -217,10 +253,10 @@
 
   itEth('(!negative test!) Set limits', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Limits', 'absolutely anything', 'OLF');
+    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
     await expect(collectionEvm.methods
       .setCollectionLimit('badLimit', 'true')
       .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
   });
-});
\ No newline at end of file
+});
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -37,13 +37,51 @@
     const description = 'Some description';
     const prefix = 'token prefix';
   
-    const {collectionId} = await helper.eth.createRefungibleCollection(owner, name, description, prefix);
+    const {collectionId} = await helper.eth.createRFTCollection(owner, name, description, prefix);
     const data = (await helper.rft.getData(collectionId))!;
+    const collection = helper.rft.getCollectionObject(collectionId);
+
+    expect(data.name).to.be.eq(name);
+    expect(data.description).to.be.eq(description);
+    expect(data.raw.tokenPrefix).to.be.eq(prefix);
+    expect(data.raw.mode).to.be.eq('ReFungible');
+
+    const options = await collection.getOptions();
+
+    expect(options.tokenPropertyPermissions).to.be.empty;
+  });
+
+  
+
+  itEth('Create collection with properties', async ({helper}) => {
+    const owner = await helper.eth.createAccountWithBalance(donor);
+
+    const name = 'CollectionEVM';
+    const description = 'Some description';
+    const prefix = 'token prefix';
+    const baseUri = 'BaseURI';
+
+    const {collectionId} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);
 
+    const collection = helper.rft.getCollectionObject(collectionId);
+    const data = (await collection.getData())!;
+    
     expect(data.name).to.be.eq(name);
     expect(data.description).to.be.eq(description);
     expect(data.raw.tokenPrefix).to.be.eq(prefix);
     expect(data.raw.mode).to.be.eq('ReFungible');
+
+    const options = await collection.getOptions();
+    expect(options.tokenPropertyPermissions).to.be.deep.equal([
+      {
+        key: 'URI',
+        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
+      },
+      {
+        key: 'URISuffix',
+        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
+      },
+    ]);
   });
   
   // this test will occasionally fail when in async environment.
@@ -71,7 +109,7 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');
 
     const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
     await collection.methods.setCollectionSponsor(sponsor).send();
@@ -90,7 +128,7 @@
 
   itEth('Set limits', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'INSI');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');
     const limits = {
       accountTokenOwnershipLimit: 1000,
       sponsoredDataSize: 1024,
@@ -133,7 +171,7 @@
       .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())
       .to.be.false;
     
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Exister', 'absolutely anything', 'WIWT');
+    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Exister', 'absolutely anything', 'WIWT');
     expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
       .methods.isCollectionExist(collectionAddress).call())
       .to.be.true;
@@ -196,7 +234,7 @@
   itEth('(!negative test!) Check owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const peasant = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');
+    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');
     const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);
     const EXPECTED_ERROR = 'NoPermission';
     {
@@ -219,7 +257,7 @@
 
   itEth('(!negative test!) Set limits', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
+    const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
     await expect(collectionEvm.methods
       .setCollectionLimit('badLimit', 'true')
modifiedtests/src/eth/evmCoder.test.tsdiffbeforeafterboth
--- a/tests/src/eth/evmCoder.test.ts
+++ b/tests/src/eth/evmCoder.test.ts
@@ -65,7 +65,7 @@
   
   itEth('Call non-existing function', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.eth.createNonfungibleCollection(owner, 'EVMCODER', '', 'TEST');
+    const collection = await helper.eth.createNFTCollection(owner, 'EVMCODER', '', 'TEST');
     const contract = await helper.ethContract.deployByCode(owner, 'Test', getContractSource(collection.collectionAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c'));
     const testContract = await helper.ethContract.deployByCode(owner, 'Test', getContractSource(collection.collectionAddress, contract.options.address));
     {
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -124,8 +124,7 @@
 		address rftTokenAddress;
 		UniqueRefungibleToken rftTokenContract;
 		if (nft2rftMapping[_collection][_token] == 0) {
-			rftTokenId = rftCollectionContract.nextTokenId();
-			rftCollectionContract.mint(address(this), rftTokenId);
+            rftTokenId = rftCollectionContract.mint(address(this));
 			rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
 			nft2rftMapping[_collection][_token] = rftTokenId;
 			rft2nftMapping[rftTokenAddress] = Token(_collection, _token);
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -62,10 +62,10 @@
 const mintRFTToken = async (helper: EthUniqueHelper, owner: string, fractionalizer: Contract, amount: bigint): Promise<{
   nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string
 }> => {
-  const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+  const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
   const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-  const nftTokenId = await nftContract.methods.nextTokenId().call();
-  await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+  const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+  const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
   await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});
   await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});
@@ -92,7 +92,7 @@
   itEth('Set RFT collection', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 10n);
     const fractionalizer = await deployContract(helper, owner);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const rftContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
 
     await rftContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});
@@ -121,7 +121,7 @@
   itEth('Set Allowlist', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
     const {contract: fractionalizer} = await initContract(helper, owner);
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
 
     const result1 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});
     expect(result1.events).to.be.like({
@@ -146,10 +146,10 @@
   itEth('NFT to RFT', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -231,7 +231,7 @@
 
   itEth('call setRFTCollection twice', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
 
     const fractionalizer = await deployContract(helper, owner);
@@ -244,7 +244,7 @@
 
   itEth('call setRFTCollection with NFT collection', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
 
     const fractionalizer = await deployContract(helper, owner);
@@ -257,7 +257,7 @@
   itEth('call setRFTCollection while not collection admin', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
     const fractionalizer = await deployContract(helper, owner);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
 
     await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())
       .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);
@@ -278,10 +278,10 @@
   itEth('call nft2rft without setting RFT collection for contract', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const fractionalizer = await deployContract(helper, owner);
 
@@ -293,10 +293,10 @@
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
     const nftOwner = await helper.eth.createAccountWithBalance(donor, 10n);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
     await nftContract.methods.transfer(nftOwner, 1).send({from: owner});
 
 
@@ -310,10 +310,10 @@
   itEth('call nft2rft while not in list of allowed accounts', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -325,10 +325,10 @@
   itEth('call nft2rft while fractionalizer doesnt have approval for nft token', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -341,11 +341,11 @@
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
     const fractionalizer = await deployContract(helper, owner);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call({from: owner}))
       .to.be.rejectedWith(/RFT collection is not set$/g);
   });
@@ -354,18 +354,18 @@
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
     const {contract: fractionalizer} = await initContract(helper, owner);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())
       .to.be.rejectedWith(/Wrong RFT collection$/g);
   });
 
   itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
-    const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');
+    const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
 
     const fractionalizer = await deployContract(helper, owner);
@@ -373,9 +373,9 @@
     await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});
     await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});
 
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())
       .to.be.rejectedWith(/No corresponding NFT token found$/g);
   });
@@ -386,7 +386,7 @@
 
     const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);
     const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);
-    
+
     const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);
     const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);
     await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});
@@ -420,7 +420,7 @@
     await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())
       .to.be.rejectedWith(/TransferNotAllowed$/g);
   });
-  
+
   itEth('fractionalize NFT with RFT transfers disallowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
@@ -432,10 +432,10 @@
     await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send({from: owner});
     await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);
 
-    const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');
+    const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});
     await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});
modifiedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -116,6 +116,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeCollectionOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "collectionOwner",
     "outputs": [
@@ -329,15 +338,6 @@
       { "internalType": "address", "name": "sponsor", "type": "address" }
     ],
     "name": "setCollectionSponsor",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "address", "name": "newOwner", "type": "address" }
-    ],
-    "name": "setOwner",
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -7,7 +7,7 @@
   helper: EthUniqueHelper,
   owner: string,
 ): Promise<{ collectionId: number, collectionAddress: string, contract: Contract }> => {
-  const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
+  const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
 
   const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
   await contract.methods.setCollectionNesting(true).send({from: owner});
@@ -29,74 +29,53 @@
     itEth('NFT: allows an Owner to nest/unnest their token', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const {collectionId, contract} = await createNestingCollection(helper, owner);
-  
-      // Create a token to be nested
-      const targetNFTTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetNFTTokenId,
-      ).send({from: owner});
-  
+
+      // Create a token to be nested to
+      const mintingTargetNFTTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetNFTTokenId = mintingTargetNFTTokenIdResult.events.Transfer.returnValues.tokenId;
       const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetNFTTokenId);
-  
+
       // Create a nested token
-      const firstTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        targetNftTokenAddress,
-        firstTokenId,
-      ).send({from: owner});
-  
+      const mintingFirstTokenIdResult = await contract.methods.mint(targetNftTokenAddress).send({from: owner});
+      const firstTokenId = mintingFirstTokenIdResult.events.Transfer.returnValues.tokenId;
       expect(await contract.methods.ownerOf(firstTokenId).call()).to.be.equal(targetNftTokenAddress);
-  
+
       // Create a token to be nested and nest
-      const secondTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        secondTokenId,
-      ).send({from: owner});
-  
+      const mintingSecondTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const secondTokenId = mintingSecondTokenIdResult.events.Transfer.returnValues.tokenId;
+
       await contract.methods.transfer(targetNftTokenAddress, secondTokenId).send({from: owner});
-  
       expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(targetNftTokenAddress);
-  
+
       // Unnest token back
       await contract.methods.transferFrom(targetNftTokenAddress, owner, secondTokenId).send({from: owner});
       expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);
     });
-  
+
     itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(helper, owner);
       await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
-  
+
       // Create a token to nest into
-      const targetNftTokenId = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        targetNftTokenId,
-      ).send({from: owner});
+      const mintingtargetNftTokenIdResult = await contractA.methods.mint(owner).send({from: owner});
+      const targetNftTokenId = mintingtargetNftTokenIdResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA1 = helper.ethAddress.fromTokenId(collectionIdA, targetNftTokenId);
-  
+
       // Create a token for nesting in the same collection as the target
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
-  
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
+
       // Create a token for nesting in a different collection
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        owner,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+      const mintingTokenIdBResult = await contractB.methods.mint(owner).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
       // Nest
       await contractA.methods.transfer(nftTokenAddressA1, nftTokenIdA).send({from: owner});
       expect(await contractA.methods.ownerOf(nftTokenIdA).call()).to.be.equal(nftTokenAddressA1);
-  
+
       await contractB.methods.transfer(nftTokenAddressA1, nftTokenIdB).send({from: owner});
       expect(await contractB.methods.ownerOf(nftTokenIdB).call()).to.be.equal(nftTokenAddressA1);
     });
@@ -105,112 +84,88 @@
   describe('Negative Test: EVM Nesting', async() => {
     itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId, contract} = await createNestingCollection(helper, owner);
       await contract.methods.setCollectionNesting(false).send({from: owner});
-  
+
       // Create a token to nest into
-      const targetNftTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetNftTokenId,
-      ).send({from: owner});
-  
-      const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetNftTokenId);
-  
+      const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetTokenId = mintingTargetTokenIdResult.events.Transfer.returnValues.tokenId;
+      const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetTokenId);
+
       // Create a token to nest
-      const nftTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        nftTokenId,
-      ).send({from: owner});
-  
+      const mintingNftTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const nftTokenId = mintingNftTokenIdResult.events.Transfer.returnValues.tokenId;
+
       // Try to nest
       await expect(contract.methods
         .transfer(targetNftTokenAddress, nftTokenId)
         .call({from: owner})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows a non-Owner to nest someone else\'s token', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const malignant = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId, contract} = await createNestingCollection(helper, owner);
-  
+
       // Mint a token
-      const targetTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetTokenId,
-      ).send({from: owner});
+      const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetTokenId = mintingTargetTokenIdResult.events.Transfer.returnValues.tokenId;
       const targetTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetTokenId);
-  
+
       // Mint a token belonging to a different account
-      const tokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        malignant,
-        tokenId,
-      ).send({from: owner});
-  
+      const mintingTokenIdResult = await contract.methods.mint(malignant).send({from: owner});
+      const tokenId = mintingTokenIdResult.events.Transfer.returnValues.tokenId;
+
       // Try to nest one token in another as a non-owner account
       await expect(contract.methods
         .transfer(targetTokenAddress, tokenId)
         .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const malignant = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(helper, owner);
-  
+
       await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
-  
+
       // Create a token in one collection
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA = helper.ethAddress.fromTokenId(collectionIdA, nftTokenIdA);
-  
-      // Create a token in another collection belonging to someone else
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        malignant,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+
+      // Create a token in another collection
+      const mintingTokenIdBResult = await contractB.methods.mint(malignant).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
       // Try to drag someone else's token into the other collection and nest
       await expect(contractB.methods
         .transfer(nftTokenAddressA, nftTokenIdB)
         .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows to nest token in an unlisted collection', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {contract: contractB} = await createNestingCollection(helper, owner);
-  
+
       await contractA.methods.setCollectionNesting(true, [collectionAddressA]).send({from: owner});
-  
+
       // Create a token in one collection
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA = helper.ethAddress.fromTokenId(collectionIdA, nftTokenIdA);
-  
+
       // Create a token in another collection
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        owner,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+      const mintingTokenIdBResult = await contractB.methods.mint(owner).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
+
       // Try to nest into a token in the other collection, disallowed in the first
       await expect(contractB.methods
         .transfer(nftTokenAddressA, nftTokenIdB)
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -29,7 +29,7 @@
       [alice] = await helper.arrange.createAccounts([10n], donor);
     });
   });
-  
+
   itEth('totalSupply', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {});
     await collection.mintToken(alice);
@@ -68,6 +68,16 @@
 
     expect(owner).to.equal(caller);
   });
+
+  itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {
+    const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});
+    const caller = helper.eth.createAccount();
+
+    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
+
+    expect(await contract.methods.name().call()).to.equal('test');
+    expect(await contract.methods.symbol().call()).to.equal('TEST');
+  });
 });
 
 describe('Check ERC721 token URI for NFT', () => {
@@ -79,34 +89,29 @@
     });
   });
 
-  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {
+  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
 
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});
-    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-    
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    result = await contract.methods.mint(
-      receiver,
-      nextTokenId,
-    ).send();
 
+    const result = await contract.methods.mint(receiver).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
+
     if (propertyKey && propertyValue) {
       // Set URL or suffix
-      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();
+      await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();
     }
 
     const event = result.events.Transfer;
     expect(event.address).to.be.equal(collectionAddress);
     expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.be.equal(receiver);
-    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);
+    expect(event.returnValues.tokenId).to.be.equal(tokenId);
 
-    return {contract, nextTokenId};
+    return {contract, nextTokenId: tokenId};
   }
 
   itEth('Empty tokenURI', async ({helper}) => {
@@ -115,18 +120,18 @@
   });
 
   itEth('TokenURI from url', async ({helper}) => {
-    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');
+    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');
     expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');
   });
 
-  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {
+  itEth('TokenURI from baseURI', async ({helper}) => {
     const {contract, nextTokenId} = await setup(helper, 'BaseURI_');
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');
   });
 
   itEth('TokenURI from baseURI + suffix', async ({helper}) => {
     const suffix = '/some/suffix';
-    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);
+    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);
     expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);
   });
 });
@@ -146,24 +151,19 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
 
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Minty', '6', '6');
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-    const nextTokenId = await contract.methods.nextTokenId().call();
 
-    expect(nextTokenId).to.be.equal('1');
-    const result = await contract.methods.mintWithTokenURI(
-      receiver,
-      nextTokenId,
-      'Test URI',
-    ).send();
+    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
 
     const event = result.events.Transfer;
     expect(event.address).to.be.equal(collectionAddress);
     expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.be.equal(receiver);
-    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);
 
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
 
     // TODO: this wont work right now, need release 919000 first
     // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
@@ -216,7 +216,7 @@
 
     {
       const result = await contract.methods.burn(tokenId).send({from: caller});
-      
+
       const event = result.events.Transfer;
       expect(event.address).to.be.equal(collectionAddress);
       expect(event.returnValues.from).to.be.equal(caller);
@@ -322,7 +322,7 @@
       [alice] = await helper.arrange.createAccounts([10n], donor);
     });
   });
-  
+
   itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const spender = helper.eth.createAccount();
@@ -403,7 +403,7 @@
 
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
-    
+
     const events: any = [];
     contract.events.allEvents((_: any, event: any) => {
       events.push(event);
@@ -428,7 +428,7 @@
 
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
-    
+
     const events: any = [];
     contract.events.allEvents((_: any, event: any) => {
       events.push(event);
@@ -455,13 +455,14 @@
 
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
-    
+
     const events: any = [];
     contract.events.allEvents((_: any, event: any) => {
       events.push(event);
     });
 
     await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});
+
     if (events.length == 0) await helper.wait.newBlocks(1);
     const event = events[0];
 
@@ -479,13 +480,14 @@
 
     const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
-    
+
     const events: any = [];
     contract.events.allEvents((_: any, event: any) => {
       events.push(event);
     });
 
     await token.transfer(alice, {Ethereum: receiver});
+
     if (events.length == 0) await helper.wait.newBlocks(1);
     const event = events[0];
 
@@ -509,7 +511,23 @@
 
   itEth('Returns collection name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+    const tokenPropertyPermissions = [{
+      key: 'URI',
+      permission: {
+        mutable: true,
+        collectionAdmin: true,
+        tokenOwner: false,
+      },
+    }];
+    const collection = await helper.nft.mintCollection(
+      alice,
+      {
+        name: 'oh River',
+        tokenPrefix: 'CHANGE',
+        properties: [{key: 'ERC721Metadata', value: '1'}],
+        tokenPropertyPermissions,
+      },
+    );
 
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
     const name = await contract.methods.name().call();
@@ -518,10 +536,26 @@
 
   itEth('Returns symbol name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+    const tokenPropertyPermissions = [{
+      key: 'URI',
+      permission: {
+        mutable: true,
+        collectionAdmin: true,
+        tokenOwner: false,
+      },
+    }];
+    const collection = await helper.nft.mintCollection(
+      alice,
+      {
+        name: 'oh River',
+        tokenPrefix: 'CHANGE',
+        properties: [{key: 'ERC721Metadata', value: '1'}],
+        tokenPropertyPermissions,
+      },
+    );
 
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
     const symbol = await contract.methods.symbol().call();
     expect(symbol).to.equal('CHANGE');
   });
-});
\ No newline at end of file
+});
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -146,6 +146,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeCollectionOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "collectionOwner",
     "outputs": [
@@ -260,12 +269,9 @@
     "type": "function"
   },
   {
-    "inputs": [
-      { "internalType": "address", "name": "to", "type": "address" },
-      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
-    ],
+    "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
     "name": "mint",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
     "type": "function"
   },
@@ -287,7 +293,7 @@
           { "internalType": "uint256", "name": "field_0", "type": "uint256" },
           { "internalType": "string", "name": "field_1", "type": "string" }
         ],
-        "internalType": "struct Tuple8[]",
+        "internalType": "struct Tuple6[]",
         "name": "tokens",
         "type": "tuple[]"
       }
@@ -300,11 +306,10 @@
   {
     "inputs": [
       { "internalType": "address", "name": "to", "type": "address" },
-      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
       { "internalType": "string", "name": "tokenUri", "type": "string" }
     ],
     "name": "mintWithTokenURI",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
     "type": "function"
   },
@@ -476,15 +481,6 @@
       { "internalType": "address", "name": "sponsor", "type": "address" }
     ],
     "name": "setCollectionSponsor",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "address", "name": "newOwner", "type": "address" }
-    ],
-    "name": "setOwner",
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -118,7 +118,7 @@
     const deployer = await helper.eth.createAccountWithBalance(donor);
     const caller = await helper.eth.createAccountWithBalance(donor);
     const contract = await helper.eth.deployFlipper(deployer);
-    
+
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     await contract.methods.flip().send({from: caller});
     const finalCallerBalance = await helper.balance.getEthereum(caller);
@@ -129,7 +129,7 @@
     const deployer = await helper.eth.createAccountWithBalance(donor);
     const caller = await helper.eth.createAccountWithBalance(donor);
     const contract = await deployProxyContract(helper, deployer);
-    
+
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     const initialContractBalance = await helper.balance.getEthereum(contract.options.address);
     await contract.methods.flip().send({from: caller});
@@ -138,7 +138,7 @@
     expect(finalCallerBalance < initialCallerBalance).to.be.true;
     expect(finalContractBalance == initialContractBalance).to.be.true;
   });
-  
+
   itEth('Fee for nested calls to native methods is withdrawn from the user', async({helper}) => {
     const CONTRACT_BALANCE = 2n * helper.balance.getOneTokenNominal();
 
@@ -146,7 +146,7 @@
     const caller = await helper.eth.createAccountWithBalance(donor);
     const contract = await deployProxyContract(helper, deployer);
 
-    const collectionAddress = (await contract.methods.createNonfungibleCollection().send({from: caller, value: Number(CONTRACT_BALANCE)})).events.CollectionCreated.returnValues.collection;
+    const collectionAddress = (await contract.methods.createNFTCollection().send({from: caller, value: Number(CONTRACT_BALANCE)})).events.CollectionCreated.returnValues.collection;
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     const initialContractBalance = await helper.balance.getEthereum(contract.options.address);
     await contract.methods.mintNftToken(collectionAddress).send({from: caller});
@@ -155,7 +155,7 @@
     expect(finalCallerBalance < initialCallerBalance).to.be.true;
     expect(finalContractBalance == initialContractBalance).to.be.true;
   });
-  
+
   itEth('Fee for nested calls to create*Collection methods is withdrawn from the user and from the contract', async({helper}) => {
     const CONTRACT_BALANCE = 2n * helper.balance.getOneTokenNominal();
     const deployer = await helper.eth.createAccountWithBalance(donor);
@@ -164,7 +164,7 @@
 
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     const initialContractBalance = await helper.balance.getEthereum(contract.options.address);
-    await contract.methods.createNonfungibleCollection().send({from: caller, value: Number(CONTRACT_BALANCE)});
+    await contract.methods.createNFTCollection().send({from: caller, value: Number(CONTRACT_BALANCE)});
     const finalCallerBalance = await helper.balance.getEthereum(caller);
     const finalContractBalance = await helper.balance.getEthereum(contract.options.address);
     expect(finalCallerBalance < initialCallerBalance).to.be.true;
@@ -176,9 +176,9 @@
     const BIG_FEE = 3n * helper.balance.getOneTokenNominal();
     const caller = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);
-        
-    await expect(collectionHelper.methods.createNonfungibleCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
-    await expect(collectionHelper.methods.createNonfungibleCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
+
+    await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
+    await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
 
   itEth('Negative test: call createRFTCollection with wrong fee', async({helper}) => {
@@ -186,7 +186,7 @@
     const BIG_FEE = 3n * helper.balance.getOneTokenNominal();
     const caller = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);
-        
+
     await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
     await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
@@ -227,16 +227,15 @@
           InnerContract(innerContract).flip();
         }
 
-        function createNonfungibleCollection() external payable {
+        function createNFTCollection() external payable {
           address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
-		      address nftCollection = CollectionHelpers(collectionHelpers).createNonfungibleCollection{value: msg.value}("A", "B", "C");
+		      address nftCollection = CollectionHelpers(collectionHelpers).createNFTCollection{value: msg.value}("A", "B", "C");
           emit CollectionCreated(nftCollection);
         }
 
         function mintNftToken(address collectionAddress) external  {
           UniqueNFT collection = UniqueNFT(collectionAddress);
-          uint256 tokenId = collection.nextTokenId();
-          collection.mint(msg.sender, tokenId);
+          uint256 tokenId = collection.mint(msg.sender);
           emit TokenMinted(tokenId);
         }
 
modifiedtests/src/eth/proxy/UniqueNFTProxy.soldiffbeforeafterboth
--- a/tests/src/eth/proxy/UniqueNFTProxy.sol
+++ b/tests/src/eth/proxy/UniqueNFTProxy.sol
@@ -120,20 +120,19 @@
         return proxied.mintingFinished();
     }
 
-    function mint(address to, uint256 tokenId)
+    function mint(address to)
         external
         override
-        returns (bool)
+        returns (uint256)
     {
-        return proxied.mint(to, tokenId);
+        return proxied.mint(to);
     }
 
     function mintWithTokenURI(
         address to,
-        uint256 tokenId,
         string memory tokenUri
-    ) external override returns (bool) {
-        return proxied.mintWithTokenURI(to, tokenId, tokenUri);
+    ) external override returns (uint256) {
+        return proxied.mintWithTokenURI(to, tokenUri);
     }
 
     function finishMinting() external override returns (bool) {
@@ -169,7 +168,7 @@
         return proxied.mintBulk(to, tokenIds);
     }
 
-    function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
+    function mintBulkWithTokenURI(address to, Tuple6[] memory tokens)
         external
         override
         returns (bool)
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -101,7 +101,7 @@
 
   itEth('Can perform mint()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'A', 'A');
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
 
@@ -111,13 +111,11 @@
     await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();
 
     {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      expect(nextTokenId).to.be.equal('1');
-      const result = await contract.methods.mintWithTokenURI(
-        receiver,
-        nextTokenId,
-        'Test URI',
-      ).send({from: caller});
+      const nextTokenId = await contract.methods.nextTokenId().call()
+      const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});
+      const tokenId = result.events.Transfer.returnValues.tokenId;
+      expect(tokenId).to.be.equal('1');
+
       const events = helper.eth.normalizeEvents(result.events);
       events[0].address = events[0].address.toLocaleLowerCase();
 
@@ -128,12 +126,12 @@
           args: {
             from: '0x0000000000000000000000000000000000000000',
             to: receiver,
-            tokenId: nextTokenId,
+            tokenId,
           },
         },
       ]);
 
-      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
     }
   });
 
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -31,31 +31,23 @@
 
   itEth('totalSupply', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'TotalSupply', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, nextTokenId).send();
+
+    await contract.methods.mint(caller).send();
+
     const totalSupply = await contract.methods.totalSupply().call();
     expect(totalSupply).to.equal('1');
   });
 
   itEth('balanceOf', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'BalanceOf', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
+    await contract.methods.mint(caller).send();
+    await contract.methods.mint(caller).send();
+    await contract.methods.mint(caller).send();
 
     const balance = await contract.methods.balanceOf(caller).call();
     expect(balance).to.equal('3');
@@ -63,11 +55,11 @@
 
   itEth('ownerOf', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'OwnerOf', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const owner = await contract.methods.ownerOf(tokenId).call();
     expect(owner).to.equal(caller);
@@ -76,11 +68,11 @@
   itEth('ownerOf after burn', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'OwnerOf-AfterBurn', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
     await tokenContract.methods.repartition(2).send();
@@ -95,11 +87,11 @@
   itEth('ownerOf for partial ownership', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Partial-OwnerOf', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
     await tokenContract.methods.repartition(2).send();
@@ -124,30 +116,25 @@
   itEth('Can perform mint()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Minty', '6', '6');
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    const result = await contract.methods.mintWithTokenURI(
-      receiver,
-      nextTokenId,
-      'Test URI',
-    ).send();
 
+    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
+
     const event = result.events.Transfer;
     expect(event.address).to.equal(collectionAddress);
     expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.equal(receiver);
-    expect(event.returnValues.tokenId).to.equal(nextTokenId);
+    const tokenId = event.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
 
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
   });
 
   itEth('Can perform mintBulk()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'MintBulky', '6', '6');
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'MintBulky', '6', '6', '');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
 
     {
@@ -179,11 +166,11 @@
 
   itEth('Can perform burn()', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Burny', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Burny', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     {
       const result = await contract.methods.burn(tokenId).send();
       const event = result.events.Transfer;
@@ -197,12 +184,13 @@
   itEth('Can perform transferFrom()', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'TransferFromy', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'TransferFromy', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
-    await contract.methods.mint(caller, tokenId).send();
 
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);
     await tokenContract.methods.repartition(15).send();
@@ -241,15 +229,15 @@
   itEth('Can perform transfer()', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Transferry', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     {
       const result = await contract.methods.transfer(receiver, tokenId).send();
-      
+
       const event = result.events.Transfer;
       expect(event.address).to.equal(collectionAddress);
       expect(event.returnValues.from).to.equal(caller);
@@ -271,11 +259,11 @@
   itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Transferry-Partial-to-Full', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Partial-to-Full', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
@@ -300,11 +288,11 @@
   itEth('transfer event on transfer from full ownership to partial ownership', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Transferry-Full-to-Partial', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Full-to-Partial', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
@@ -340,11 +328,11 @@
   itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Feeful-Transfer-From', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer-From', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
@@ -354,11 +342,11 @@
   itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Feeful-Transfer', '6', '6');
+    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transfer(receiver, tokenId).send());
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
@@ -381,8 +369,24 @@
 
   itEth('Returns collection name', async ({helper}) => {
     const caller = helper.eth.createAccount();
-    const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11'});
-    
+    const tokenPropertyPermissions = [{
+      key: 'URI',
+      permission: {
+        mutable: true,
+        collectionAdmin: true,
+        tokenOwner: false,
+      },
+    }];
+    const collection = await helper.rft.mintCollection(
+      alice,
+      {
+        name: 'Leviathan',
+        tokenPrefix: '11',
+        properties: [{key: 'ERC721Metadata', value: '1'}],
+        tokenPropertyPermissions,
+      },
+    );
+
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
     const name = await contract.methods.name().call();
     expect(name).to.equal('Leviathan');
@@ -390,8 +394,25 @@
 
   itEth('Returns symbol name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Leviathan', '', '12');
-    const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
+    const tokenPropertyPermissions = [{
+      key: 'URI',
+      permission: {
+        mutable: true,
+        collectionAdmin: true,
+        tokenOwner: false,
+      },
+    }];
+    const {collectionId} = await helper.rft.mintCollection(
+      alice,
+      {
+        name: 'Leviathan',
+        tokenPrefix: '12',
+        properties: [{key: 'ERC721Metadata', value: '1'}],
+        tokenPropertyPermissions,
+      },
+    );
+
+    const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);
     const symbol = await contract.methods.symbol().call();
     expect(symbol).to.equal('12');
   });
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -146,6 +146,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeCollectionOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "collectionOwner",
     "outputs": [
@@ -260,12 +269,9 @@
     "type": "function"
   },
   {
-    "inputs": [
-      { "internalType": "address", "name": "to", "type": "address" },
-      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
-    ],
+    "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
     "name": "mint",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
     "type": "function"
   },
@@ -287,7 +293,7 @@
           { "internalType": "uint256", "name": "field_0", "type": "uint256" },
           { "internalType": "string", "name": "field_1", "type": "string" }
         ],
-        "internalType": "struct Tuple8[]",
+        "internalType": "struct Tuple6[]",
         "name": "tokens",
         "type": "tuple[]"
       }
@@ -300,11 +306,10 @@
   {
     "inputs": [
       { "internalType": "address", "name": "to", "type": "address" },
-      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
       { "internalType": "string", "name": "tokenUri", "type": "string" }
     ],
     "name": "mintWithTokenURI",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
     "type": "function"
   },
@@ -476,15 +481,6 @@
       { "internalType": "address", "name": "sponsor", "type": "address" }
     ],
     "name": "setCollectionSponsor",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "address", "name": "newOwner", "type": "address" }
-    ],
-    "name": "setOwner",
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -76,34 +76,28 @@
     });
   });
 
-  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {
+  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
 
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});
-    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
+    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    result = await contract.methods.mint(
-      receiver,
-      nextTokenId,
-    ).send();
 
-    if (propertyKey && propertyValue) {
-      // Set URL or suffix
-      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();
-    }
+    const result = await contract.methods.mint(receiver).send();
 
     const event = result.events.Transfer;
+    const tokenId = event.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
     expect(event.address).to.be.equal(collectionAddress);
     expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.be.equal(receiver);
-    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);
 
-    return {contract, nextTokenId};
+    if (propertyKey && propertyValue) {
+      // Set URL or suffix
+      await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();
+    }
+
+    return {contract, nextTokenId: tokenId};
   }
 
   itEth('Empty tokenURI', async ({helper}) => {
@@ -112,18 +106,18 @@
   });
 
   itEth('TokenURI from url', async ({helper}) => {
-    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');
+    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');
     expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');
   });
 
-  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {
+  itEth('TokenURI from baseURI', async ({helper}) => {
     const {contract, nextTokenId} = await setup(helper, 'BaseURI_');
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');
   });
 
   itEth('TokenURI from baseURI + suffix', async ({helper}) => {
     const suffix = '/some/suffix';
-    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);
+    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);
     expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);
   });
 });
@@ -294,11 +288,11 @@
   itEth('Receiving Transfer event on burning into full ownership', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Devastation', '6', '6');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Devastation', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);
 
@@ -484,11 +478,12 @@
   itEth('Default parent token address and id', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
 
-    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sands', '', 'GRAIN');
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sands', '', 'GRAIN');
     const collectionContract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const tokenId = await collectionContract.methods.nextTokenId().call();
-    await collectionContract.methods.mint(owner, tokenId).send();
+
+    const result = await collectionContract.methods.mint(owner).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);
 
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -43,12 +43,12 @@
     if(!imports) return function(path: string) {
       return {error: `File not found: ${path}`};
     };
-  
+
     const knownImports = {} as {[key: string]: string};
     for(const imp of imports) {
       knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();
     }
-  
+
     return function(path: string) {
       if(path in knownImports) return {contents: knownImports[path]};
       return {error: `File not found: ${path}`};
@@ -71,7 +71,7 @@
         },
       },
     }), {import: await this.findImports(imports)})).contracts[`${name}.sol`][name];
-  
+
     return {
       abi: out.abi,
       object: '0x' + out.evm.bytecode.object,
@@ -94,7 +94,7 @@
   }
 
 }
-  
+
 class NativeContractGroup extends EthGroupBase {
 
   contractHelpers(caller: string): Contract {
@@ -145,14 +145,14 @@
   async createAccountWithBalance(donor: IKeyringPair, amount=100n) {
     const account = this.createAccount();
     await this.transferBalanceFromSubstrate(donor, account, amount);
-  
+
     return account;
   }
 
   async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=100n, inTokens=true) {
     return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));
   }
-  
+
   async getCollectionCreationFee(signer: string) {
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
     return await collectionHelper.methods.collectionCreationFee().call();
@@ -174,22 +174,32 @@
     return await this.helper.callRpc('api.rpc.eth.call', [{from: signer, to: contractAddress, data: abi}]);
   }
 
-  async createNonfungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
+  async createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-        
-    const result = await collectionHelper.methods.createNonfungibleCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
+    const result = await collectionHelper.methods.createNFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
+
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
 
     return {collectionId, collectionAddress};
   }
 
-  async createRefungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
+  async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
+    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
+
+    const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix)
+
+    await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
+
+    return {collectionId, collectionAddress};
+  }
+
+  async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-        
+
     const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
@@ -198,6 +208,16 @@
     return {collectionId, collectionAddress};
   }
 
+  async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
+    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
+
+    const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix)
+
+    await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
+
+    return {collectionId, collectionAddress};
+  }
+
   async deployCollectorContract(signer: string): Promise<Contract> {
     return await this.helper.ethContract.deployByCode(signer, 'Collector', `
     // SPDX-License-Identifier: UNLICENSED
@@ -288,7 +308,7 @@
     };
     return await this.helper.arrange.calculcateFee(address, wrappedCode);
   }
-}  
+}
 
 class EthAddressGroup extends EthGroupBase {
   extractCollectionId(address: string): number {
@@ -319,8 +339,8 @@
   normalizeAddress(address: string): string {
     return '0x' + address.substring(address.length - 40);
   }
-}  
- 
+}
+
 export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
 
 export class EthUniqueHelper extends DevUniqueHelper {
@@ -373,4 +393,3 @@
     return newHelper;
   }
 }
-  
\ No newline at end of file
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1026,6 +1026,10 @@
     return (await this.helper.callRpc('api.rpc.unique.collectionProperties', [collectionId, propertyKeys])).toHuman();
   }
 
+  async getCollectionOptions(collectionId: number) {
+    return (await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId])).toHuman();
+  }
+
   /**
    * Deletes onchain properties from the collection.
    *
@@ -2839,6 +2843,10 @@
     return await this.helper.collection.getTokenNextSponsored(this.collectionId, tokenId, addressObj);
   }
 
+  async getOptions() {
+    return await this.helper.collection.getCollectionOptions(this.collectionId);
+  }
+
   async setSponsor(signer: TSigner, sponsorAddress: TSubstrateAccount) {
     return await this.helper.collection.setSponsor(signer, this.collectionId, sponsorAddress);
   }