Skip to main content

REST API

Send a transaction to the contract

MethodPathSummary
POST/transactionThis method checks an incoming transaction, builds the zkSNARK Merkle tree proof, and sends the transaction to the Pool contract. The transaction doesn't process immediately because contract interaction is completed in a serial manner. Incoming transactions are put into the job queue. The method returns jobId on success.

Request Parameters

ParameterInTypeRequiredDescription
proofbodyDictionarytrueTransaction proof (built by a client)
memobodyStringtrueMemo block, Base64-encoded
tx_typebodyIntegertrue0: deposit, 1: transfer, 2: withdrawal
depositSignaturebodyStringfalseAccount nullifier signature with the client's native chain private key (for withdrawal tx only)

Responses

StatusDescription
201: CreatedTransaction has been pushed to the job queue
400: Bad RequestError while parsing the input JSON
500: Internal Server ErrorSomething went wrong

Get the job status

MethodPathSummary
GET/job/:idReturns incoming transaction processing state. jobId is returned by /transaction method.

Request Parameters

ParameterInTypeRequiredDescription
idqueryIntegertrueJob identifier

Responses

StatusDescription
200: OKJob status in body
404: Not FoundJob with specified ID not found
500: Internal Server ErrorSomething went wrong

Query transactions

MethodPathSummary
GET/transactions/:limit/:offsetReturns memo blocks and out commits for transactions at the specified offset. This method is used by clients to synchronize account state.

Request Parameters

ParameterInTypeRequiredDescription
limitqueryIntegertrueNumber of transactions to query
offsetqueryIntegertrueThe Index of the first transaction (in the Merkle tree, should be a multiple of 128)

Responses

StatusDescription
200: OKArray of requested transactions
400: Bad RequestCheck query parameters
500: Internal Server ErrorSomething went wrong

Get Merkle tree proofs at the specified position

MethodPathSummary
GET/merkle/proof?[index]Get Merkle tree proofs at the specified position

Responses

StatusDescription
200: OKSuccess
404: Not FoundSpecified index doesn't exist in the current tree
500: Internal Server ErrorSomething went wrong

Get Merkle tree root node at the specified index

MethodPathSummary
GET/merkle/root/:indexGet Merkle tree root node at the specified index

Request Parameters

ParameterInTypeRequiredDescription
indexqueryIntegerfalse-

Responses

StatusDescription
200: OKSuccess
404: Not FoundIndex not exist in the Merkle tree
500: Internal Server ErrorSomething went wrong

Calculate transaction proof

MethodPathSummary
POST/proof_txBuilds zkSNARK proof for the transaction based on public and secret transaction input calculated by a client. WARNING: This is a debug method used to decrease client overhead. DO NOT use in production, as the client should pass public and secret transactional data. This significantly decreases overall security!

Request Parameters

ParameterInTypeRequiredDescription
pubbodyDictionarytruePublic inputs for the circuit
secbodyDictionarytrueSecret inputs for the circuit

Responses

StatusDescription
200: OKProof has been calculated successfully
400: Bad RequestError in the public or secret input
500: Internal Server ErrorSomething went wrong

Get the next index in the Merkle tree

MethodPathSummary
GET/delta_indexGet the next index in the Merkle tree

Responses

StatusDescription
200: OKAn integer value of the index
500: Internal Server ErrorSomething went wrong

Get current Merkle tree root and delta index

MethodPathSummary
GET/infoGet current Merkle tree root and delta index

Responses

StatusDescription
200: OKSuccess
500: Internal Server ErrorSomething went wrong