Skip to main content

zkCloudWorkerClient

API class for interacting with the zkCloudWorker

Index

Constructors

constructor

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

    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

    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?: any; success: boolean }>
  • Gets the result of the job using serverless api call


    Parameters

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

      the data for the jobResult call

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

    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

    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

    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

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

    where result is the result of the job