point-issuer
v1.0.6
Published
This Typescript SDK allows clients to issue points to their users. It provides flexibility to issue points for off-chain actions.
Downloads
11
Readme
Point-Issuer SDK
This Typescript SDK allows clients to issue points to their users. It provides flexibility to issue points for off-chain actions.
Installation
Install the SDK with npm:
npm install points-issuer
Usage
First, import the PointsClient
class:
import {PointsClient} from "point-issuer";
Then, create a new instance of the PointsClient
.
const sdkClient = new PointsClient('your-api-key', 'your-campaign-id');
Distribute Points
To distribute points, use the distribute
method:
sdkClient.distribute('event-name', { points: 100, address: '0x...' }, { metadataKey: 'metadataValue' });
Get Points by address
To get the points for an address, use the getPoints
method:
const points = await sdkClient.getPoints('0x...');
console.log(points);
Get Points by event & address
To get the points for an address by event, use the getPointsByEvent
method:
const points = await pointsClient.getPointsByEvent('0x...', 'event-name');
Error Handling
If an error occurs while making a request, the SDK will log the error message to the console.