Options
All
  • Public
  • Public/Protected
  • All
Menu

The class of AINFT 721 object.

Hierarchy

Index

Constructors

  • new Ainft721Object(objectInfo: { id: string; metadata?: Metadata; name: string; owner: string; slug?: string; symbol: string }, ain: default, baseUrl: string): Ainft721Object
  • Constructor of Ainft721Object. Do not use it directly; use the nft.get() function instead.

    Parameters

    • objectInfo: { id: string; metadata?: Metadata; name: string; owner: string; slug?: string; symbol: string }

      The information about the AINFT object.

      • id: string

        The ID of AINFT object.

      • Optional metadata?: Metadata

        The metadata of AINFT object.

      • name: string

        The name of AINFT object.

      • owner: string

        The owner of AINFT object.

      • Optional slug?: string

        The URL slug of AINFT object.

      • symbol: string

        The symbol of AINFT object.

    • 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 Ainft721Object

Properties

ain: default

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

ainize?: default

The Ainize object for send request to AIN blockchain.

appId: string

The ID of app in AIN blockchain.

baseUrl: string = ''

The base url of api server of AINFT Factory.

id: string

The ID of AINFT object.

metadata?: Metadata

The metadata of AINFT object.

name: string

The name of AINFT object.

owner: string

Owner of AINFT object.

route: string

The subpath of api server request url.

slug?: null | string

The URL slug of AINFT object.

symbol: string

The symbol of AINFT object.

Methods

  • Gets specific token object.

    Parameters

    • tokenId: string

      Token ID of AINFT.

    Returns Promise<AinftToken>

    Returns AINFT token instance.

    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);
    }
  • getTxBodyForMint(ownerAddress: string, to: string, tokenId: string): Promise<any>
  • Gets transaction body to mint token.

    Parameters

    • ownerAddress: string

      The address of the AINFT object owner.

    • to: string

      The address the AINFT will be send.

    • tokenId: string

      Token ID of AINFT.

    Returns Promise<any>

    Returns transaction body without signature.

    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 result = await ainftObject.getTxBodyForMint('RECEIVER-ADDRESS', 'TARGET-TOKEN-ID');
    console.log(result); // trasacntion body for mint.
    }
  • getTxBodyForTransfer(from: string, to: string, tokenId: string): Promise<any>
  • Gets transaction body to transfer token.

    Parameters

    • from: string

      The address the AINFT will be send from.

    • to: string

      The address the AINFT will be send to.

    • tokenId: string

      Token ID of AINFT.

    Returns Promise<any>

    Returns transaction body without signature.

    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 result = await ainftObject.getTxBodyForTransfer('SENDER-ADDRESS', 'RECEIVER-ADDRESS', 'TARGET-TOKEN-ID');
    console.log(result); // trasacntion body for transfer.
    }
  • mint(to: string, tokenId: string): Promise<any>
  • Mints new token.

    Parameters

    • to: string

      The address the AINFT will be minted.

    • tokenId: string

      Token ID of 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 result = await ainftObject.mint('RECEIVER-ADDRESS', 'TARGET-TOKEN-ID');
    console.log(result); // result of transaction.
    }
  • 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
  • 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.

  • transfer(from: string, to: string, tokenId: string): Promise<any>
  • Transfers token to other account.

    Parameters

    • from: string

      The address the AINFT will be send from.

    • to: string

      The address the AINFT will be send to.

    • tokenId: string

      Token ID of 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 result = await ainftObject.transfer('SENDER-ADDRESS', 'RECEIVER-ADDRESS', 'TARGET-TOKEN-ID');
    console.log(result); // result of transaction.
    }
  • getAppId(objectId: string): string

Generated using TypeDoc