README
snet-sdk-web
SingularityNET SDK for Browser (Web)
Getting Started
These instructions are for the development and use of the SingularityNET SDK for JavaScript on web platform like browsers.
Installation
npm install snet-sdk-web
Usage
The SingularityNET SDK allows you to import compiled client libraries for your service or services of choice and make calls to those services programmatically from your application by setting up state channels with the providers of those services and making gRPC calls to the SingularityNET daemons for those services by selecting a channel with sufficient funding and supplying the appropriate metadata for authentication.
import SnetSDK from 'snet-sdk-web';
import config from './config';
const sdk = new SnetSDK(config);
Now, the instance of the sdk can be used to instantiate clients for SingularityNET services. To interact with those services, the sdk needs to be supplied with the compiled gRPC client libraries.
This SDK uses gRPC-web by improbable engineering. To generate the gRPC client libraries, follow the instructions given by the gRPC-web
package here.
The api to invoke gRPC methods against a service is similar to that of the gRPC-web
package used.
import { <ServiceName> } from '<path_to_grpc_service_file>'
import { <Message> } from '<path_to_grpc_message_file>'
const client = sdk.createServiceClient("<org_id>", "<service_id>")
This generates a service client which can be used to make gRPC calls to the desired service. You can then invoke service specific calls as follows
client.invoke(<ServiceName>.<MethodName>, <InvokeRpcOptions>);
More details about can be found on the official documentation.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.