Virtual API

Our API manual

The OntropySDK package provides developers with a set of tools to seamlessly interact with the Ontropy Virtual Rollup protocol. This protocol is designed to enhance user experience and reduce transaction costs across a wide range of Web3 applications. By solving common UX challenges and offering modern cryptographic primitives, the Ontropy Virtual Rollup protocol significantly improves the effectiveness of Web3 applications.

For installation instruction, go to Installing the SDK. For a complete list of the exposed methods and APIs, see API Reference.

The OntropySDK provides several methods to interact with the Virtual Rollup protocol. Here are some of the key methods:

  • startSession(sessionId: string, times: number = 0): Starts a new session in the Virtual Rollup protocol.

  • joinSession(sessionId: string): Joins an existing session in the Virtual Rollup protocol.

  • leaveSession(sessionId: string): Leaves the current session in the Virtual Rollup protocol.

  • generateRoundProof(roundId: string, metadata: string, participantCount: number): Generates a cryptographic proof for a round in the Virtual Rollup protocol.

  • closeSession(schnorrSignature, metadata, result): Closes the current session and validates the session result.

Here is an example of how to use the SDK:

import { OntropySDK } from "ontropy-sdk";

const sdk = new OntropySDK("libp2p", "your-ethereum-address");

// Start a new session
sdk.startSession("session-id");

// Generate a round proof
sdk.generateRoundProof("round-id", "metadata", 10);

// Start the next round
sdk.startNextRound(session);

  1. startSession(sessionId: string, times: number = 0): Promise<RollupSession>

This function starts a new session in the Virtual Rollup protocol. It takes two parameters: sessionId which is the ID of the session to start, and times which is the number of retry attempts (default is 0). It returns a promise that resolves to the started RollupSession.

sdk.startSession("session-id");
  1. joinSession(sessionId: string): Promise<RollupSession>

This function allows a participant to join an existing session in the Virtual Rollup protocol. It takes one parameter: sessionId which is the ID of the session to join. It returns a promise that resolves to the joined RollupSession.

sdk.joinSession("session-id");
  1. generateRoundProof(roundId: string, metadata: string, participantCount: number): Promise<boolean>

This function generates a cryptographic proof for a round in the Ontropy Virtual Rollup protocol. It takes three parameters: roundId which is the ID of the round to generate a proof for, metadata which is additional metadata for the proof, and participantCount which is the number of participants in the round. It returns a promise that resolves to true if the proof is generated successfully.

sdk.generateRoundProof("round-id", "metadata", 10);
  1. startNextRound(session: RollupSession)

This function starts the next round in the Ontropy Virtual Rollup protocol. It takes one parameter: session which is the current RollupSession.

sdk.startNextRound(session);
  1. joinNextRound(session: RollupSession)

This function allows the participant to join the next round in the Ontropy Virtual Rollup protocol. It takes one parameter: session which is the current RollupSession.

sdk.joinNextRound(session);
  1. leaveSession(sessionId: string): Promise<void>

This function allows the participant to leave the current session in the Ontropy Virtual Rollup protocol. It takes one parameter: sessionId which is the ID of the session to leave. It returns a promise that resolves when the session is left.

sdk.leaveSession("session-id");

Please note that the above examples are simplified and you may need to handle promises and async/await in your actual code.

Feel free to contribute to the OntropySDK package by submitting issues and pull requests on the GitHub repository.

This package is available under the Commercial Software License. Please email the copy of this license agreement to dev@ontropy.io to use the SDK.

If you have any questions or suggestions, please contact us at dev@ontropy.io.

Last updated