Typescript
Learn how to get set up, reward tokens, create badges, and reward badges with our TypeScript SDK.
1
Install
Copy
npm install @openformat/sdk ethers@^5
2
Instantiate SDK
Before you can instantiate the SDK you need to Create an Application.
Copy
import { Chains, OpenFormatSDK } from "@openformat/sdk";
const sdk = new OpenFormatSDK({
network: Chains.arbitrumSepolia,
appId: "YOUR_APP_ID",
signer: process.env.PRIVATE_KEY, // Your wallet's private key
});
3
Reward Token
Copy
import { ActivityType, RewardType, toWei } from "@openformat/sdk";
const params = [
{
receiver: "0x821EFACF307Add10fd9A812624955cbEF943265c",
id: "signed-up",
address: "0x72092f038f94833f37cc197874ac8c9b02689ac1",
amount: toWei("1"),
actionType: RewardActionType.MINT,
rewardType: RewardType.TOKEN,
uri: "ipfs://metadata",
},
];
await sdk.Reward.trigger(params);
4
Create Badge
Copy
async function createBadge() {
const params: Reward_CreateBadgeParams = {
name: "My special Badge",
symbol: "My special Badge",
};
const badge = await sdk.Reward.createBadge(params);
}
5
Reward Badge
Copy
import { ActivityType, RewardType } from "@openformat/sdk";
const params = [
{
receiver: "0x03755352654D73DA06756077Dd7f040ADcE3Fd58",
id: "signed-up",
address: "0x36db942d490f8091b91e020a8a934040ca426968",
amount: 1,
actionType: RewardActionType.MINT,
rewardType: RewardType.BADGE,
uri: "ipfs://metadata",
},
];
await sdk.Reward.trigger(params);
Assistant
Responses are generated using AI and may contain mistakes.