Skip to main content

MinaNFT

MinaNFT is the class for the NFT, wrapper around the MinaNFTContract

Hierarchy

Index

Constructors

constructor

  • new MinaNFT(params: { address: PublicKey; creator?: string; escrow?: Field; name: string; nameService?: PublicKey; owner?: Field; storage?: string }): MinaNFT
  • Create MinaNFT object


    Parameters

    • params: { address: PublicKey; creator?: string; escrow?: Field; name: string; nameService?: PublicKey; owner?: Field; storage?: string }

      arguments

    Returns MinaNFT

Properties

address

address: PublicKey

Public key of the deployed NFT zkApp

creator

creator: string

Creator of the NFT

escrow

escrow: Field

Escrow of the NFT - Poseidon hash of three escrow's public keys

isMinted

isMinted: boolean

True if the NFT is minted

metadata

metadata: Map<string, PrivateMetadata>

name

name: string

Name of the NFT

nameService

nameService: undefined | PublicKey

Public key of the NFT Name Service

owner

owner: Field

Owner of the NFT - Poseidon hash of owner's public key

storage

storage: string

Storage of the NFT - IPFS (i:...) or Arweave (a:...) hash string

tokenId

tokenId: undefined | Field

Token ID of the NFT Name Service

version

version: UInt64

Version of the NFT, increases by one with the changing of the metadata or owner

staticbadgeVerificationKey

badgeVerificationKey: undefined | VerificationKey

staticbadgeVerifierVerificationKey

badgeVerifierVerificationKey: undefined | VerificationKey

staticcache

cache: undefined | Cache

staticescrowVerificationKey

escrowVerificationKey: undefined | VerificationKey

staticnamesVerificationKey

namesVerificationKey: undefined | VerificationKey

staticredactedMapVerificationKey

redactedMapVerificationKey: undefined | VerificationKey

statictransferVerificationKey

transferVerificationKey: undefined | VerificationKey

staticupdateVerificationKey

updateVerificationKey: undefined | VerificationKey

staticupdaterVerificationKey

updaterVerificationKey: undefined | VerificationKey

staticverificationKey

verificationKey: undefined | VerificationKey

staticverifierVerificationKey

verifierVerificationKey: undefined | VerificationKey

Methods

publicapprove

  • approve(approvalData: MinaNFTApproval): Promise<undefined | PendingTransaction>
  • Approve the escrow for the NFT. Compiles the contract if needed.


    Parameters

    Returns Promise<undefined | PendingTransaction>

publiccheckState

  • checkState(info?: string): Promise<boolean>
  • Checks that on-chain state is equal to off-chain state


    Parameters

    • info: string = ""

      additional info for logging

    Returns Promise<boolean>

    true if on-chain state is equal to off-chain state

publiccommit

  • commit(commitData: MinaNFTCommit): Promise<undefined | PendingTransaction>
  • Commit updates of the MinaNFT to blockchain Generates recursive proofs for all updates, than verify the proof locally and send the transaction to the blockchain


    Parameters

    Returns Promise<undefined | PendingTransaction>

publicgetMetadata

  • Gets public attribute


    Parameters

    • key: string

      key of the attribute

    Returns undefined | PrivateMetadata

    value of the attribute

publicgetMetadataRootAndMap

  • Calculates a root and MerkleMap of the publicAttributes


    Returns { map: MetadataMap; root: Metadata }

    Root and MerkleMap of the publicAttributes

publicloadMetadata

  • loadMetadata(metadataURI?: undefined | string, skipCalculatingMetadataRoot?: boolean): Promise<void>
  • Load metadata from blockchain and IPFS/Arweave


    Parameters

    • metadataURI: undefined | string = undefined

      URI of the metadata. Obligatorily in case there is private metadata as private metadata cannot be fetched from IPFS/Arweave

    • skipCalculatingMetadataRoot: boolean = false

      Skip calculating metadata root in case metadataURI is not provided and NFT contains private data

    Returns Promise<void>

publicmint

  • mint(minaData: MinaNFTMint, skipCalculatingMetadataRoot?: boolean): Promise<undefined | PendingTransaction>
  • Mints an NFT. Deploys and compiles the MinaNFT contract if needed.


    Parameters

    • minaData: MinaNFTMint

      MinaNFTMint mint data

    • skipCalculatingMetadataRoot: boolean = false

      skip calculating metadata root in case the NFT is imported from the JSON that do not contains private metadata and therefore the root cannot be calculated

    Returns Promise<undefined | PendingTransaction>

publicprepareCommitData

publictoJSON

  • toJSON(params?: { includePrivateData?: boolean; increaseVersion?: boolean }): object
  • Converts to JSON


    Parameters

    • params: { includePrivateData?: boolean; increaseVersion?: boolean } = {}

      parameters

    Returns object

    JSON object

publictransfer

  • transfer(transferData: MinaNFTTransfer): Promise<undefined | PendingTransaction>
  • Transfer the NFT. Compiles the contract if needed.


    Parameters

    Returns Promise<undefined | PendingTransaction>

publicupdate

publicupdateField

publicupdateFile

publicupdateFileData

  • updateFileData(params: { data: FileData; isPrivate?: boolean; key: string; type?: string }): void
  • updates PrivateMetadata


    Parameters

    • params: { data: FileData; isPrivate?: boolean; key: string; type?: string }

      arguments

    Returns void

publicupdateImage

publicupdateMap

publicupdateMetadata

  • updates Metadata


    Parameters

    Returns void

publicupdateText

publicstaticcommitPreparedData

  • commitPreparedData(commitData: { deployer: PrivateKey; nameService: MinaNFTNameService; nonce?: number; ownerPublicKey: string; preparedCommitData: MinaNFTCommitData }): Promise<undefined | PendingTransaction>
  • Commit updates of the MinaNFT to blockchain using prepared data Generates recursive proofs for all updates, than verify the proof locally and send the transaction to the blockchain


    Parameters

    Returns Promise<undefined | PendingTransaction>

publicstaticcompile

  • compile(rollup?: boolean): Promise<VerificationKey>
  • Compiles MinaNFT contract


    Parameters

    • rollup: boolean = false

    Returns Promise<VerificationKey>

    verification key

publicstaticcompileBadge

  • compileBadge(): Promise<VerificationKey>
  • Compiles MinaNFTVerifierBadge contract


    Returns Promise<VerificationKey>

    verification key

publicstaticcompileEscrow

  • compileEscrow(): Promise<VerificationKey>
  • Compiles Escrow contract


    Returns Promise<VerificationKey>

    verification key

publicstaticcompileRedactedMap

  • compileRedactedMap(): Promise<VerificationKey>
  • Compiles RedactedMinaNFTMapCalculation contract


    Returns Promise<VerificationKey>

    verification key

publicstaticcompileVerifier

  • compileVerifier(): Promise<VerificationKey>
  • Compiles MinaNFTVerifier contract


    Returns Promise<VerificationKey>

    verification key

publicstaticfee

  • fee(): Promise<UInt64>
  • Get current Mina network fee


    Returns Promise<UInt64>

    current Mina network fee

publicstaticfromJSON

  • fromJSON(params: { metadataURI: string; nameServiceAddress: PublicKey; skipCalculatingMetadataRoot?: boolean }): MinaNFT
  • Load metadata from blockchain and IPFS/Arweave


    Parameters

    • params: { metadataURI: string; nameServiceAddress: PublicKey; skipCalculatingMetadataRoot?: boolean }

      arguments

    Returns MinaNFT

    MinaNFT object

publicstaticmapFromJSON

  • mapFromJSON(json: object): Map<string, string>
  • Creates a Map from JSON


    Parameters

    • json: object

      json with map data

    Returns Map<string, string>

    map as JSON object

publicstaticminaInit

publicstaticsetCache

  • setCache(cache: Cache): void
  • Sets a cache for prover keys


    Parameters

    • cache: Cache

    Returns void

publicstaticsetCacheFolder

  • setCacheFolder(folder?: string): void
  • Sets a cache folder for prover keys


    Parameters

    • folder: string = "./cache"

      folder for prover keys default is "./cache"

    Returns void

publicstaticstringFromField

  • stringFromField(field: Field): string
  • Converts a Field to a string


    Parameters

    • field: Field

      Field to convert

    Returns string

    string

publicstaticstringFromFields

  • stringFromFields(fields: Field[]): string
  • Converts a Field[] to a string


    Parameters

    • fields: Field[]

      Fields to convert

    Returns string

    string

publicstaticstringToField

  • stringToField(item: string): Field
  • Converts a string to a Field


    Parameters

    • item: string

      string to convert

    Returns Field

    string as a Field

publicstaticstringToFields

  • stringToFields(item: string): Field[]
  • Converts a string to a Fields


    Parameters

    • item: string

      string to convert

    Returns Field[]

    string as a Field[]

publicstatictransactionInfo

  • transactionInfo(tx: PendingTransaction, description?: string, wait?: boolean): Promise<void>
  • Logs transaction info


    Parameters

    • tx: PendingTransaction

      transaction

    • description: string = ""

      description

    • wait: boolean = true

      wait for transaction to be included in the block

    Returns Promise<void>

publicstaticurlFromStorage

  • urlFromStorage(storage: Storage): string
  • Converts a Storage to a storage url string


    Parameters

    Returns string

    string

publicstaticurlFromStorageString

  • urlFromStorageString(storageStr: string): string
  • Converts a string "i:..." or "a:..." to a storage url string


    Parameters

    • storageStr: string

      string to convert

    Returns string

    string

publicstaticverify

  • verify(params: { deployer: PrivateKey; nameServiceAddress: PublicKey; nft: PublicKey; proof: RedactedMinaNFTMapStateProof; verifier: PublicKey }): Promise<PendingTransaction>
  • Verify Redacted MinaNFT proof


    Parameters

    • params: { deployer: PrivateKey; nameServiceAddress: PublicKey; nft: PublicKey; proof: RedactedMinaNFTMapStateProof; verifier: PublicKey }

      arguments

    Returns Promise<PendingTransaction>

publicstaticwait

  • wait(tx: PendingTransaction): Promise<boolean>
  • Parameters

    • tx: PendingTransaction

    Returns Promise<boolean>