Unique Pallet - Extrinsics

🔸addCollectionAdmin

Description

Adds an admin of the specified collection.

Declaration

addCollectionAdmin(collectionId, newAdminId)

collectionId [u32] - an ID of the collection which will be affected.

newAdminId [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

Code Example

api.tx.unique.addColletionAdmin(2, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'})
api.tx.unique.addColletionAdmin(5, {Ethereum: '0x1C9d253C8f9f4b25d32F107B0460aEEb4b6fefb5'})

🔸addToAllowList

Description

Adds an address to collection allow list.

Declaration

addToAllowList(collectionId, newAdminId)

collectionId [u32] - an ID of the collection which will be affected.

newAdminId [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

Code Example

api.tx.unique.addToAllowList(2, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'})
api.tx.unique.addToAllowList(5, {Ethereum: '0x1C9d253C8f9f4b25d32F107B0460aEEb4b6fefb5'})

🔸approve

Description

Sets, changes or remove approved address to transfer the ownership of an NFT.

Declaration

approve(spender, collectionId, itemId, amount)

spender [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

collectionId [u32] - an ID of the collection which will be affected.

itemId [u32] - token Id that will be affected.

amount [u128] - use 1 for NFT.

Code Example

api.tx.unique.approve({Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'}, 10, 200, 1)

🔸burnFrom

Description

Destroys a concrete instance of NFT on behalf of the specific user.

Declaration

burnFrom(collectionId, from, itemId, value)

collectionId [u32] - an ID of the collection which will be affected.

from [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

itemId [u32] - token Id that will be affected.

value [u128] - use 1 for NFT.

Code Example

api.tx.unique.burnFrom(10, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'}, 200, 1) 

🔸burnItem

Description

Destroys a concrete instance of NFT on behalf of the owner.

Declaration

burnItem(collectionId, itemId, value)

collectionId [u32] - an ID of the collection which will be affected.

itemId [u32] - token Id that will be affected.

value [u128] - use 1 for NFT.

Code Example

api.tx.unique.burnItem(10, 200, 1) 

🔸changeCollectionOwner

Description

Changes the collection owner to the specified address.

Declaration

changeCollectionOwner(collectionId, newOwner)

collectionId [u32] - an ID of the collection which will be affected.

newOwner [string] - the new owner address in the Substrate format. Returns boolean (true on success, false on fail).

Code Example

api.tx.unique.changeCollectionOwner(10, '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21')

🔸confirmSponsorship

Description

Confirms consent to sponsor the collection on behalf of the signer. Returns bool true on success.

Declaration

confirmSponsorship(collectionId)

collectionId [u32] - an ID of the collection which will be used.

Code Example

const result = api.tx.unique.confirmSponsorship(10)
await result.sign(keyring) 

🔸createCollection

Description

Deprecated. Please use the createCollectionEx method.

🔸createCollectionEx

Description

Creates a new collection on the chain. The signer must have sufficient funds to create the collection. Returns a UniqueNFTCollection object from the created collection

Declaration

createCollectionEx(collectionOptions)

collectionOptions [UpDataStructsCreateCollectionData] - structure that contains the data in the JSON format. See below.

click to expand
   collectionOptions: {
      name: string,
      description: string,
      tokenPrefix: string,
      pendingSponsor?: string,
      permissions: {
      access?: "AllowList" | "Normal",
      mintMode?: boolean,
      nesting: {collectionAdmin: boolean, tokenOwner: boolean, restricted: null | Number[]}
      },
      limits?: ChainLimits,
      properties?: ({key: string, value: string})[],
      tokenPropertyPermissions?: ({key: string, permission: {mutable?: boolean, collectionAdmin?: boolean, tokenOwner?: boolean}})[]
   }

Code Example

api.tx.unique.createCollectionEx({name: 'test', description: 'test description', tokenPrefix: 'tst'})

🔸createItem

Description

This method creates an item in the NFT collection and assigns it to the specified owner.

Declaration

createItem(collectionId, owner, data)

collectionId [u32] - an ID of the collection which will be affected.

owner [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

data [UpDataStructsCreateItemData] - structure that contains the token data in the JSON format. See below.

click to expand
  collectionOptions: {
      name: string,
      description: string,
      tokenPrefix: string,
      pendingSponsor?: string,
      permissions: {
      access?: "AllowList" | "Normal",
      mintMode?: boolean,
      nesting: {collectionAdmin: boolean, tokenOwner: boolean, restricted: null | Number[]}
      },
      limits?: ChainLimits,
      properties?: ({key: string, value: string})[],
      tokenPropertyPermissions?: ({key: string, permission: {mutable?: boolean, collectionAdmin?: boolean, tokenOwner?: boolean}})[]
  }

Code Example

api.tx.unique.createItem(1, {Substrate: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'}, {key: 'name', value: 'Alice'})

🔸createMultipleItems

Description

Deprecated. Please use the createMultipleItemsEx method.

🔸createMultipleItemsEx

Description

Creates several new tokens at once in the specified collection (up to 100 at a time). All property keys must be present in the collection. Returns an object with the transaction result.

Declaration

createMultipleItemsEx(collectionId, data)

collectionId [u32] - an ID of the collection which will be affected.

data [UpDataStructsCreateItemExData] - structure that contains the address and token data in the JSON format. See below.

click to expand
data: ({
    owner: {Substrate?: string, Ethereum?: string},
    properties?: ({key: string, value: string})[]
  )[]

Code Example

api.tx.unique.createMultipleItemsEx(1, [
  {{Substrate: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'}, {key: 'name', value: 'Alice'}},
  {{Substrate: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'}, {key: 'name', value: 'Bob'}}
])

🔸deleteCollectionProperties

Description

Deletes on-chain properties from the collection. Returns bool true on success.

Declaration

deleteCollectionProperties(collectionId, propertyKeys)

collectionId [u32] - an ID of the collection which will be affected.

propertyKeys [PropertyKeys vector] - the array of the properties that will be deleted.

Code example

api.tx.unique.deleteCollectionProperties(1, ['is_substrate'])

🔸deleteTokenProperties

Description

Deletes properties from an NFT token. Returns bool true on success.

Declaration

deleteTokenProperties(collectionId, tokenId, propertyKeys)

collectionId [u32] - an ID of the collection which will be affected.

tokenId [u32] - token Id that will be affected.

propertyKeys [PropertyKeys vector] - the array of the properties that will be deleted.

Code example

api.tx.unique.deleteTokenProperties(6, 200, ['name'])

🔸destroyCollection

Description

Destroys a collection if there are tokens in it and if the signer has sufficient permissions.

Declaration

destroyCollection(collectionId)

collectionId [u32] - an ID of the collection which will be affected.

Code Example

api.tx.unique.destroyCollection(7)

🔸removeCollectionAdmin

Description

Removes a collection administrator. An admin address can remove itself. Returns bool true on success.

Declaration

removeCollectionAdmin(collectionId,accountId)

collectionId [u32] - an ID of the collection which will be affected.

accountId [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

Code Example

api.tx.unique.removeCollectionAdmin(2, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'})
api.tx.unique.removeCollectionAdmin(5, {Ethereum: '0x1C9d253C8f9f4b25d32F107B0460aEEb4b6fefb5'})

🔸removeCollectionSponsor

Description

Removes the collection sponsor. Switch back to the pay-per-own-transaction model.

Declaration

removeCollectionSponsor(collectionId)

collectionId [u32] - an ID of the collection which will be affected.

Code Example

api.tx.unique.removeCollectionSponsor(7)

🔸removeFromAllowList

Description

Remove an address from the allow list.

Declaration

removeFromAllowList(collectionId, address)

collectionId [u32] - an ID of the collection which will be affected.

address [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

Code Example

api.tx.unique.removeFromAllowList(2, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'})
api.tx.unique.removeFromAllowList(5, {Ethereum: '0x1C9d253C8f9f4b25d32F107B0460aEEb4b6fefb5'})

🔸setCollectionLimits

Description

Sets the limits of the collection. At least one limit must be specified for a correct call. Returns bool true on success.

Declaration

setCollectionLimits(collectionId, newLimit)

collectionId [u32] - an ID of the collection which will be affected.

limits [UpDataStructsCollectionLimits] - structure that contains the limits for the collection. See below.

click to expand
limits: {
    accountTokenOwnershipLimit?: Number,
    sponsoredDataSize?: Number,
    sponsoredDataRateLimit?: Number,
    tokenLimit?: Number,
    sponsorTransferTimeout?: Number,
    sponsorApproveTimeout?: Number,
    ownerCanTransfer?: boolean,
    ownerCanDestroy?: boolean,
    transfersEnabled?: boolean
}

Code Example

api.tx.unique.setCollectionLimits(7, {transfersEnabled: false})

🔸setCollectionPermissions

Description

Sets on-chain permissions for selected collection. Returns bool true on success.

Declaration

setCollectionPermissions(collectionId, newLimit)

collectionId [u32] - an ID of the collection which will be affected.

newLimit [UpDataStructsCollectionPermissions] - structure that contains the permissions for a collection. See below.

click to expand
permissions: {
    access?: 'Normal' | 'AllowList',
    mintMode?: boolean,
    nesting?: {tokenOwner: boolean, collectionAdmin: boolean, restricted: null | Number[]}
}

Code Example

api.tx.unique.setCollectionPermissions(6, {mintMode: false})

🔸setCollectionProperties

Description

Sets on-chain properties for the specified collection. Returns bool true on success.

Declaration

setCollectionProperties(collectionId, properties)

collectionId [u32] - an ID of the collection which will be affected.

properties [UpDataStructsProperty vector] - array of the structures that represent a collection property.

Code Example

api.tx.unique.setCollectionProperties(6, [{key: 'name', value: 'Alice'}, {key: 'is_substrate', value: 'true'}])

🔸setCollectionSponsor

Description

Sets a sponsor address for a collection.

Declaration

setCollectionSponsor(collectionId, newSponsor)

collectionId [u32] - an ID of the collection which will be affected.

newSponsor [string] - the new sponsor address in the Substrate format. Returns boolean (true on success, false on fail).

Code Example

api.tx.unique.setCollectionSponsor(10, '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21')

🔸setTransfersEnabledFlag

Description

Set the transfers_enabled value for a specified collection.

Declaration

setTransfersEnabledFlag(collectionId, value)

collectionId [u32] - an ID of the collection which will be affected.

value [boolean] - true or false depending on whether you want to enable/disable the flag.

Code Example

api.tx.unique.setTransfersEnabledFlag(7, true)

🔸setTokenProperties

Declaration

setTokenProperties(collectionId, tokenId, properties)

collectionId [u32] - an ID of the collection which will be affected.

tokenId [u32] - token Id that will be affected.

properties [UpDataStructsProperty vector] - an array of structures that contains properties for a token.

Code Example

api.tx.unique.setTokenProperties(6, 200, [{key: 'name', value: 'Alice'}])

🔸setPropertyPermissions

Description

Sets permissions for the token properties. The token can contain only properties with permissions. Returns bool true on success.

Declaration

setPropertyPermissions(collectionId, propertyPermissions)

collectionId [u32] - an ID of the collection which will be affected.

propertyPermissions [UpDataStructsPropertyKeyPermission vector] - an array of structures that contains permissions for properties.

click to expand
tokenPropertyPermissions: {
      key: string, 
      permission: {
          mutable?: boolean, 
          collectionAdmin?: boolean, 
          tokenOwner?: boolean
    }
}

Code Example

api.tx.unique.setTokenPropertyPermissions(1, [{key: 'name', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}])

🔸transfer

Description

Transfers an NFT token from signer to a given address (Substrate or Ethereum). Returns bool true on success.

Declaration

transfer(recipient, collectionId, itemId, value)

recipient [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.

collectionId [u32] - an ID of the collection which will be affected.

itemId [u32] - token Id that will be affected.

value [u128] - use 1 for NFT.

Code Example

api.tx.unique.transfer({Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'}, 10, 200, 1)

🔸transferFrom

Description

Transfers NFT token from given address (Substrate or Ethereum) to given address (Substrate or Ethereum). The signer must be authorized to do so. Returns bool true on success.

DeclarationtransferFrom(from, recipient, collectionId, itemId, value)

from [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value. You need to specify the account which sends a token.

recipient [PalletEvmAccountBasicCrossAccountIdRepr] - an object which represents the set of the address type and its value.You need to specify the account which receives a token.

collectionId [u32] - an ID of the collection which will be affected.

itemId [u32] - token Id that will be affected.

value [u128] - use 1 for NFT.

Code Example

api.tx.unique.transferFrom({Substrate: '5CiDszBRQ7jDhPwGtrSa4EZHAgbEwhGMbNSaJDQgmYibzy44'}, {Substrate: '5CiDszBRQ7jDhPwRNBLc4EZHAgbEwhGMbNSaJDQgmYibzm21'}, 10, 200, 1)