TypeScript Client SDK
Getting Started with Calimero SDK for Typescriptβ
Our TypeScript Client SDK is a powerful tool designed to simplify the process of interacting with decentralized peer-to-peer applications installed on the node. It serves as an efficient conduit for communication between the client and the nodeβs server. This SDK is particularly beneficial for developers as it abstracts the complexities of server communication, allowing them to concentrate on the core application logic.
The SDK is built with the modern features of TypeScript, a language that is gaining popularity for its static typing and advanced capabilities. By using our SDK, developers can write applications in TypeScript, and the SDK takes care of the rest. It handles all the interactions with the server, making the development process more streamlined and efficient.
This not only enhances the overall development experience but also accelerates the deployment of innovative decentralized applications on our network. In essence, our TypeScript SDK is a comprehensive solution that makes building and interacting with decentralized applications a breeze. Itβs all about making the development process more enjoyable and productive for developers worldwide.
Componentsβ
Our TypeScript Client SDK is composed of two main components: RpcClient
and
SubscriptionsClient
. Each of these components has an interface and a class
that implements the interface. The RpcClient
interface is implemented by the
JsonRpcClient
class, and the SubscriptionsClient
interface is implemented by
the WsSubscriptionsClient
class.
These components are designed with flexibility and future growth in mind. While currently there is only one implementation of each interface, we anticipate multiple implementations in the future. This is because our server will have multiple implementations of both the Rpc server and the Subscriptions server. This design allows us to easily add new classes that implement these interfaces as our server capabilities expand.
The RpcClient
and SubscriptionsClient
interfaces define a standard set of
methods that all implementations must provide. This ensures consistency across
different implementations, making it easier for developers to switch between
different Rpc and Subscriptions servers as needed.
By designing our SDK in this way, we ensure that it remains flexible, scalable, and easy to use, regardless of how our server implementations evolve in the future.
RpcClient interfaceβ
export interface RpcClient {
query<Args, Output>(
params: RpcQueryParams<Args>,
config?: RequestConfig,
): Promise<RpcQueryResponse<Output>>;
mutate<Args, Output>(
params: RpcMutateParams<Args>,
config?: RequestConfig,
): Promise<RpcMutateResponse<Output>>;
}
export interface RequestConfig {
timeout?: number;
}
export interface RpcQueryParams<Args> {
applicationId: ApplicationId;
method: string;
argsJson: Args;
}
export interface RpcQueryResponse<Output> {
output?: Output;
}
export interface RpcMutateParams<Args> {
applicationId: ApplicationId;
method: string;
argsJson: Args;
}
export interface RpcMutateResponse<Output> {
output?: Output;
}