0.1.6 • Published 2 months ago

@unique-nft/schemas v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Unique schema toolkit

Collection encoding and decoding

Collection encoding takes some info about collection (cover image, etc.) and returns collection's properties and collection's token property permissions which are used to create a collection.

import {SchemaTools} from '@unique-nft/schemas'

const {collectionProperties, tokenPropertyPermissions} = SchemaTools.collection.encode({
  cover_image: {
    url: 'https://ipfs.unique.network/ipfs/QmcAcH4F9HYQtpqKHxBFwGvkfKb8qckXj2YWUrcc8yd24G/image1.png'
  },
})

const collectionInfo = SchemaTools.collection.decode(collectionProperties)

Token encoding and decoding

Token encoding takes some info about token (image, attributes, royalties, etc.) and returns token's properties which are used to create a token.

import {SchemaTools} from '@unique-nft/schemas'

const tokenProperties = SchemaTools.token.encode({
  image: 'https://ipfs.unique.network/ipfs/QmcAcH4F9HYQtpqKHxBFwGvkfKb8qckXj2YWUrcc8yd24G/image1.png',
  attributes: [
    {trait_type: 'gender', value: 'Female'},
    {trait_type: 'traits', value: 'Teeth Smile'},
    {trait_type: 'traits', value: 'Up Hair'}
  ],
  royalties: [
    {
      address: '5Gus5r7HSZv9ScdaTNVbFMBEsxMtc4cZBPTLfJJbLXQK8m9d', // substrate address
      percent: 0.5
    },
    {
      address: '0xd47b259722f314bd4ec2f26524e34b8a0172e49a', // ethereum address
      percent: 2
    }
  ],
})

const token = SchemaTools.token.decode(
  tokenProperties,
  {collectionProperties, tokenI2} // optional, but required to parse tokens in Unique Schema v0 and v1
)
0.1.6

2 months ago

2.1.4

2 months ago

2.1.3

2 months ago

2.1.2

2 months ago

2.1.1

3 months ago

2.1.0

3 months ago

2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

3 months ago

2.0.0-beta.0

3 months ago

0.1.4

10 months ago

0.1.5

7 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.3

12 months ago

0.1.0

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago