Skip to main content

zkCloudWorkerClient

API class for interacting with the zkCloudWorker

Index

Constructors

constructor

  • Constructor for the API class


    Parameters

    • params: { chain?: blockchain; jwt: string; webhook?: string; zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker> }

      the parameters for the API class

      • optionalchain: blockchain

        The blockchain network to use

      • jwt: string

        The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth

      • optionalwebhook: string

        The webhook for the serverless api to get the results

      • optionalzkcloudworker: (cloud: Cloud) => Promise<zkCloudWorker>

        The local worker for the serverless api to test the code locally

    Returns zkCloudWorkerClient

Properties

readonlychain

chain: blockchain

The blockchain network to use

optionalreadonlyendpoint

endpoint?: string

The endpoint of the serverless api

readonlyjwt

jwt: string

The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth

optionalreadonlylocalWorker

localWorker?: (cloud: Cloud) => Promise<zkCloudWorker>

The local worker for the serverless api to test the code locally


Type declaration

optionalreadonlywebhook

webhook?: string

The webhook for the serverless api to get the results

Methods

publicdeploy

  • deploy(data: { developer: string; packageManager: string; repo: string }): Promise<{ error?: string; jobId?: string; success: boolean }>
  • Deploys the code to the cloud using serverless api call


    Parameters

    • data: { developer: string; packageManager: string; repo: string }

      the data for the deploy call

      • developer: string

        the developer

      • packageManager: string

        the package manager to use

      • repo: string

        the repo to use

    Returns Promise<{ error?: string; jobId?: string; success: boolean }>

    where jobId is the jobId of the job

publicexecute

  • execute(data: { args?: string; developer: string; metadata?: string; mode?: string; repo: string; task: string; transactions: string[]; userId?: string }): Promise<{ error?: string; jobId?: string; result?: any; success: boolean }>
  • Starts a new job for the function call using serverless api call


    Parameters

    • data: { args?: string; developer: string; metadata?: string; mode?: string; repo: string; task: string; transactions: string[]; userId?: string }

      the data for the proof call

      • optionalargs: string

        the arguments of the job

      • developer: string

        the developer

      • optionalmetadata: string

        the metadata of the job

      • optionalmode: string

        the mode of the job execution: "sync" will not create a job, it will execute the function synchronously within 30 seconds and with the memory limit of 256 MB

      • repo: string

        the repo to use

      • task: string

        the task of the job

      • transactions: string[]

        the transactions

      • optionaluserId: string

        the userId of the job

    Returns Promise<{ error?: string; jobId?: string; result?: any; success: boolean }>

    where jonId is the jobId of the job (for async calls), result is the result of the job (for sync calls)

publicgetBalance

  • getBalance(): Promise<{ error?: string; result?: any; success: boolean }>
  • Gets the remaining balance


    Returns Promise<{ error?: string; result?: any; success: boolean }>

    where result is the balance

publicjobResult

  • jobResult(data: { includeLogs?: boolean; jobId: string }): Promise<{ error?: string; result?: string; success: false } | { error?: string; result: JobData; success: true }>
  • Gets the result of the job using serverless api call


    Parameters

    • data: { includeLogs?: boolean; jobId: string }

      the data for the jobResult call

      • optionalincludeLogs: boolean

        include logs in the result, default is false

      • jobId: string

        the jobId of the job

    Returns Promise<{ error?: string; result?: string; success: false } | { error?: string; result: JobData; success: true }>

    where result is the result of the job if the job is not finished yet, the result will be undefined if the job failed, the result will be undefined and error will be set if the job is finished, the result will be set and error will be undefined if the job is not found, the result will be undefined and error will be set

publicqueryBilling

  • queryBilling(): Promise<{ error?: string; result?: any; success: boolean }>
  • Gets the billing report for the jobs sent using JWT


    Returns Promise<{ error?: string; result?: any; success: boolean }>

    where result is the billing report

publicrecursiveProof

  • recursiveProof(data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string; webhook?: string }): Promise<{ error?: string; jobId?: string; success: boolean }>
  • Starts a new job for the proof calculation using serverless api call


    Parameters

    • data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string; webhook?: string }

      the data for the proof call

      • optionalargs: string

        the arguments of the job, should be serialized JSON or string

      • developer: string

        the developer

      • optionalmetadata: string

        the metadata of the job, should be serialized JSON or string

      • repo: string

        the repo to use

      • optionaltask: string

        the task of the job

      • transactions: string[]

        the transactions

      • optionaluserId: string

        the userId of the job

      • optionalwebhook: string

        the webhook for the job

    Returns Promise<{ error?: string; jobId?: string; success: boolean }>

    where jonId is the jobId of the job

    The developers repo should provide a zkcloudworker function that can be called with the given parameters, see the examples

publicsendTransactions

  • sendTransactions(data: { developer: string; repo: string; transactions: string[] }): Promise<{ error?: string; success: boolean; txId?: string[] }>
  • Sends transactions to the blockchain using serverless api call


    Parameters

    • data: { developer: string; repo: string; transactions: string[] }

      the data for the proof call

      • developer: string

        the developer

      • repo: string

        the repo to use

      • transactions: string[]

        the transactions

    Returns Promise<{ error?: string; success: boolean; txId?: string[] }>

    where txId is the transaction id of the transaction, in the sequence of the input transactions

publicwaitForJobResult

  • waitForJobResult(data: { interval?: number; jobId: string; maxAttempts?: number; maxErrors?: number; printLogs?: boolean }): Promise<{ error?: string; result?: any; success: boolean }>
  • Waits for the job to finish


    Parameters

    • data: { interval?: number; jobId: string; maxAttempts?: number; maxErrors?: number; printLogs?: boolean }

      the data for the waitForJobResult call

      • optionalinterval: number

        the interval between attempts, default is 20000 (20 seconds)

      • jobId: string

        the jobId of the job

      • optionalmaxAttempts: number

        the maximum number of attempts, default is 360 (2 hours)

      • optionalmaxErrors: number

        the maximum number of network errors, default is 10

      • optionalprintLogs: boolean

        print logs, default is true

    Returns Promise<{ error?: string; result?: any; success: boolean }>

    where result is the result of the job