Documentation
Enclave SDK
Query and Transaction

Defining Query and Transaction

Your application deployed on Klave is a collections of query and transaction functions. Klave SDK provides a simple way to declare query and transaction functions.

Declaring a Transaction Function

The transaction template function in Klave can take up to one parameters and the return type is always void. To declare a transaction function in your app with the SDK you just have to decorate the method signature as follow:

/**
 * @transaction
 */
export function myTransaction(): void {
    //develop your transactional logic here
}
 
/**
 * @transaction
 */
export function myTransactionWithInput(input: InputType): void {
    //develop your transactional logic here
}

Declaring a Query Function

In a similar fashion the query template function in Klave can take up to one parameters and the return type is always void. To declare a query function in your app with the SDK you just have to decorate the method signature as follow:

/**
* @query
*/
export function myQuery(): void {
    //develop your query logic here
}
 
/**
* @query
*/
export function myQueryWithInput(input: InputType): void {
    //develop your query logic here
}

Input Parameters Management

if your unique input parameter is not a native type then you have to declare and decorate it accordingly.

@serializable
export class InputType {
    success!: boolean;
    message!: string;
}

The serialisation and deserialisation of the input are automatically managed by the Klave SDK.