Class Arc19

Class representing an ARC-19 compliant NFT on Algorand. Extends CoreAsset with metadata handling for the ARC-19 standard.

Hierarchy (view full)

Constructors

  • Creates an instance of Arc19.

    Parameters

    • id: number

      The asset ID

    • params: AssetParams

      The asset parameters from the Algorand blockchain

    • network: Network

      The Algorand network this asset exists on

    • metadata: any

      The metadata associated with the asset

    Returns Arc19

Properties

assetParams: AssetParams

The asset parameters retrieved from the Algorand blockchain

id: number

The asset ID on the Algorand blockchain

metadata: any

The metadata associated with this ARC-19 asset

network: Network

The Algorand network to use

Methods

  • Gets the asset parameters

    Returns AssetParams

    The asset parameters

  • Converts an amount from decimal-adjusted units to base units

    Parameters

    • amount: number

      The amount in decimal-adjusted units

    Returns number

    The amount in base units

  • Converts an amount from base units to decimal-adjusted units

    Parameters

    • amount: number

      The amount in base units

    Returns number

    The amount adjusted for decimals

  • Gets the clawback address of the asset

    Returns string

    The clawback address or the zero address if not set

  • Gets the freeze address of the asset

    Returns string

    The freeze address or the zero address if not set

  • Gets the image as a base64 encoded string

    Returns Promise<string>

    A promise resolving to the base64 encoded image

    Throws

    Error if no image is available or fetch fails

  • Gets the image URL for this ARC-19 asset

    Returns string

    The resolved image URL

  • Gets the manager address of the asset

    Returns string

    The manager address or the zero address if not set

  • Gets the metadata associated with this ARC-19 asset

    Returns any

    The metadata object

  • Gets the metadata URL for this ARC-19 asset using the reserve address

    Returns string

    The resolved metadata URL

  • Gets the reserve address of the asset

    Returns string

    The reserve address or the zero address if not set

  • Checks if the asset has a clawback address

    Returns boolean

    True if the asset has a clawback address

  • Checks if the asset has a freeze address

    Returns boolean

    True if the asset has a freeze address

  • Checks if the asset URL uses HTTP or HTTPS protocol

    Returns boolean

    True if the URL uses HTTP or HTTPS

  • Checks if the asset has a manager address

    Returns boolean

    True if the asset has a manager address

  • Checks if the asset has a reserve address

    Returns boolean

    True if the asset has a reserve address

  • Private

    Calculates SHA256 hash of blob content

    Parameters

    • blobContent: undefined | Blob

      The blob content to hash

    Returns Promise<string>

    Promise resolving to hex-encoded hash string

    Throws

    Error if no blob content provided

  • Private

    Converts numeric codec code to string representation

    Parameters

    • code: number

      The numeric codec code

    Returns "raw" | "dag-pb" | "dag-cbor"

    The string representation of the codec

  • Creates a new ARC-19 compliant NFT on the Algorand blockchain

    Parameters

    • options: {
          clawback?: string;
          creator: {
              address: string;
              signer: TransactionSigner;
          };
          decimals?: number;
          defaultFrozen?: boolean;
          freeze?: string;
          image: {
              file: string | File;
              name: string;
          };
          ipfs: IPFS;
          manager?: string;
          name: string;
          network: Network;
          properties: any;
          total?: number;
          unitName: string;
      }

      The configuration options for creating the ARC-19 NFT

      • Optional clawback?: string

        The clawback address

      • creator: {
            address: string;
            signer: TransactionSigner;
        }

        The creator of the asset, including address and signer

        • address: string
        • signer: TransactionSigner
      • Optional decimals?: number

        The decimals for the asset

      • Optional defaultFrozen?: boolean

        Whether the asset should be frozen by default

      • Optional freeze?: string

        The freeze address

      • image: {
            file: string | File;
            name: string;
        }

        The path to the image file

        • file: string | File
        • name: string
      • ipfs: IPFS

        The IPFS instance to use for uploading

      • Optional manager?: string

        The manager address

      • name: string

        The name of the asset

      • network: Network

        The Algorand network to use

      • properties: any

        Additional properties to include in the metadata

      • Optional total?: number

        The total number of assets

      • unitName: string

        The unit name for the asset

    Returns Promise<{
        assetId: number;
        transactionId: string;
    }>

    A promise resolving to an object containing the transaction ID and asset ID

    Throws

    Error if creation fails

  • Private

    Creates a reserve address from an IPFS CID for ARC-19 template resolution

    Parameters

    • ipfsCid: string

      The IPFS CID to convert

    Returns {
        assetURL: string;
        reserveAddress: string;
    }

    The Algorand address derived from the CID

    • assetURL: string
    • reserveAddress: string
  • Fetches asset parameters from the Algorand blockchain

    Parameters

    • id: number

      The asset ID to fetch

    • network: Network

      The Algorand network to use

    Returns Promise<AssetParams>

    A promise resolving to the asset parameters

  • Creates an Arc19 instance from existing asset parameters

    Parameters

    • id: number

      The asset ID

    • assetParams: AssetParams

      The asset parameters from the blockchain

    • network: Network

      The Algorand network to use

    Returns Promise<Arc19>

    A promise resolving to an Arc19 instance

  • Creates an Arc19 instance from an existing asset ID

    Parameters

    • id: number

      The asset ID to load

    • network: Network

      The Algorand network to use

    Returns Promise<Arc19>

    A promise resolving to an Arc19 instance

    Throws

    Error if the asset cannot be loaded

  • Gets all metadata versions for an ARC-19 asset by examining transaction history

    Parameters

    • assetId: number

      The asset ID to get metadata versions for

    • network: Network

      The Algorand network to search on

    Returns Promise<Record<string, any>[]>

    Promise resolving to array of metadata versions with timestamps

    Throws

    Error if unable to fetch transaction history

  • Validates if a URL conforms to ARC-19 template-ipfs format

    Parameters

    • url: string

      The URL to validate

    Returns boolean

    True if the URL is valid ARC-19 template format

  • Checks if an asset is ARC-19 compliant based on its URL

    Parameters

    • url: string

      The asset URL to check

    Returns boolean

    True if the asset follows ARC-19 standards

  • Private

    Resolves standard URLs (HTTP/HTTPS and IPFS)

    Parameters

    • url: string

      The URL to resolve

    Returns string

    The resolved URL with proper protocol

  • Resolves template-ipfs URLs to standard IPFS URLs using reserve address Handles the ARC-19 template format: template-ipfs://{ipfscid:1:raw:reserve:sha2-256}

    Parameters

    • url: string

      The template-ipfs URL to resolve

    • reserveAddr: string

      The reserve address to use for CID generation

    Returns string

    The resolved IPFS URL or empty string if invalid

  • Updates an existing ARC-19 NFT's metadata

    Parameters

    • options: {
          assetId: number;
          image?: {
              file: string | File;
              name: string;
          };
          ipfs: IPFS;
          manager: {
              address: string;
              signer: TransactionSigner;
          };
          network: Network;
          properties?: any;
      }

      The configuration options for updating the ARC-19 NFT

      • assetId: number

        The asset ID of the NFT to update

      • Optional image?: {
            file: string | File;
            name: string;
        }

        The new image to upload and set

        • file: string | File
        • name: string
      • ipfs: IPFS

        IPFS instance for uploading content

      • manager: {
            address: string;
            signer: TransactionSigner;
        }

        The manager account with address and transaction signer

        • address: string
        • signer: TransactionSigner
      • network: Network

        The Algorand network the NFT exists on

      • Optional properties?: any

        The new properties to set in the metadata

    Returns Promise<{
        confirmedRound: undefined | bigint;
        transactionId: string;
    }>

    A promise resolving to the transaction confirmation

    Throws

    Error if update fails or manager doesn't have permission