
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@blockedprotocol/points-sdk
Advanced tools
Use the SDK to integrate Blocked Points SDK into your app in minutes. The SDK is available in Typescript and Javascript.
Contact Blocked Protocol team to receive your private keys
npm add @blockedprotocol/points-sdk
Use the newBlockedSdk
method to initialize the client, providing your API key and point system id.
import { newBlockedSdk } from "@blockedprotocol/points-sdk";
const blockedSdk = newBlockedSdk({
apiKey: "YOUR_API_KEY",
pointsSystemId: "YOUR_POINT_SYSTEM_ID",
});
By default it'll use production environment, but you can pass env: "development"
to use development environment.
Tagging each point assignment with an event name is important for tracking and analytics.
await blockedSdk.points.track("login", {
points: 100,
account: "11111111111111111111111111111111",
});
await blockedSdk.points.track("transfer_eth_cosmos", {
points: 515,
account: "22222222222222222222222222222222",
});
You can substract points for account using the negative value. The following example will decrement 50 points:
await blockedSdk.points.track("penalty", {
points: -50,
account: "11111111111111111111111111111111",
});
Get the points for an account using the getPoints method, providing the account address.
await blockedSdk.points.getPoints("11111111111111111111111111111111");
// => { points: 100 }
Get the leaderboard using the getLeaderboard method. The response defaults to the top 100 users. Pagination support coming soon
await blockedSdk.points.getLeaderboard();
// => [
// { account: "11111111111111111111111111111111", points: 100 },
// { account: "22222222222222222222222222222222", points: 515 }
// ]
Get the rank of an account in the leaderboard using the getLeaderboardRank method.
await blockedSdk.points.getLeaderboardRank("11111111111111111111111111111111");
// {
// account: '11111111111111111111111111111111',
// rank: 1,
// points: 100
// }
Get the events for a specific event name using the getEvents method.
await blockedSdk.points.getEvents({
account: "11111111111111111111111111111111", // filter by address
event: "login", // filter by event name
});
// Returns an array of events
// => [
// {
// event: 'login',
// account: '11111111111111111111111111111111',
// timestamp: 1712326918956,
// points: 100,
// }
// ]
If you don't specify the event
field, it'll return all events for a given account
User
- is an entity allows to link multiple accounts and utilize referral system
await blockedSdk.users.create([
"11111111111111111111111111111111",
"22222222222222222222222222222222",
]);
// => { id: "<USER_ID>" }
const referrerUser = blockedSdk.users.findByAccount(
"22222222222222222222222222222222"
);
await blockedSdk.users.create(["11111111111111111111111111111111"], referrerUser.id);
// => { id: "<USER_ID>" }
Returns cumulutive value for all accounts linked to user
const user = blockedSdk.users.findByAccount("11111111111111111111111111111111");
await blockedSdk.points.getPointsForUser(user.id);
// => { points: 100 }
FAQs
# Using the SDK
The npm package @blockedprotocol/points-sdk receives a total of 0 weekly downloads. As such, @blockedprotocol/points-sdk popularity was classified as not popular.
We found that @blockedprotocol/points-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.