Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unique-nft/schemas

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unique-nft/schemas

Unique Network schemas encoding, validating and decoding toolkit

  • 2.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
635
increased by108.2%
Maintainers
0
Weekly downloads
 
Created
Source

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.encode.collection({
  cover_image: {
    url: 'https://ipfs.unique.network/ipfs/QmcAcH4F9HYQtpqKHxBFwGvkfKb8qckXj2YWUrcc8yd24G/image1.png'
  },
})

const collectionInfo = SchemaTools.decode.collection(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.encode.token({
  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.decode.token(
  tokenProperties,
  {collectionProperties, tokenId} // optional, but required to parse tokens in Unique Schema v0 and v1
)

Keywords

FAQs

Package last updated on 12 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc