Options
All
  • Public
  • Public/Protected
  • All
Menu

The class of AINFT Token.

Hierarchy

Index

Constructors

  • new AinftToken(tokenInfo: { ainftObjectId: string; metadata?: object; tokenId: string; tokenURI: string }, ain: default, baseUrl: string): AinftToken
  • Create AinftToken instance. Do not use it directly; use the Ainft721Object.getToken() function instead.

    Parameters

    • tokenInfo: { ainftObjectId: string; metadata?: object; tokenId: string; tokenURI: string }

      The information about the AINFT.

      • ainftObjectId: string

        The AINFT object ID of AINFT.

      • Optional metadata?: object

        The metadata of AINFT.

      • tokenId: string

        The token ID of AINFT.

      • tokenURI: string

        The token URI of AINFT's metadata.

    • ain: default

      Ain instance to sign and send transaction to AIN blockchain.

    • baseUrl: string

      The base url to request api to AINFT factory server.

    Returns AinftToken

Properties

ain: default

The Ain object for sign and send transaction to AIN blockchain.

ainftObjectId: string

The AINFT object ID of AINFT.

ainize?: default

The Ainize object for send request to AIN blockchain.

baseUrl: string = ''

The base url of api server of AINFT Factory.

metadata?: object

The metadata of AINFT.

route: string

The subpath of api server request url.

tokenId: string

The token ID of AINFT.

tokenURI: string

The token URI of AINFT's metadata.

Methods

  • sendFormRequest(method: POST | PUT, trailingUrl: string, stringFields: {}, fileFields: {}): Promise<any>
  • Sends request that include form to api server of AINFT Factory. Used to upload asset data.

    Parameters

    • method: POST | PUT

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • stringFields: {}

      The string fields of form.

      • [key: string]: string
    • fileFields: {}

      The file fields of form.

      • [key: string]: { buffer: Buffer; filename: string }
        • buffer: Buffer
        • filename: string

    Returns Promise<any>

    Returns response of api request.

  • sendRequest(method: HttpMethod, trailingUrl: string, data?: Record<string, any>): Promise<any>
  • Sends request to api server of AINFT Factory. Authenticate by signing data.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    Returns Promise<any>

    Returns response of api request.

  • sendRequestWithoutSign(method: HttpMethod, trailingUrl: string, data?: Record<string, any>, headers?: AxiosRequestHeaders): Promise<any>
  • Sends request to api server of AINFT Factory. Used when authentication is not required.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    • Optional headers: AxiosRequestHeaders

      The headers of Http api request.

    Returns Promise<any>

    Returns response of api request.

  • setBaseUrl(baseUrl: string): void
  • setMetadata(metadata: object): Promise<any>
  • Sets AINFT's metadata.

    Parameters

    • metadata: object

      The value to be set as metadata for the AINFT.

    Returns Promise<any>

    Returns transaction result.

    import AinftJs from '@ainft-team/ainft-js';

    const ainftJs = new AinftJs('YOUR-PRIVATE-KEY');
    async function main() {
    const ainftObject = await ainftJs.nft.get('YOUR-AINFT-OBJECT-ID');
    const ainft = await ainftObject.getToken('YOUR-TOKEN-ID);
    const metadata = {
    image: '...',
    }
    const result = await ainft.setMetadata(metadata);
    console.log(result) // result of transaction.
    }
  • signData(data: any): string | Promise<string>
  • Sign the data with the private key that the user has registered.

    Parameters

    • data: any

      The data to sign.

    Returns string | Promise<string>

    Returns signature string.

Generated using TypeDoc