@mallow-labs/mallow-rewards-sdk
v0.1.2
Published
mallow rewards sdk
Readme
@mallow-labs/mallow-rewards-sdk
TypeScript client SDK for the Mallow Rewards Solana program (MRWDBkgyy3t3aA9C85DhmPfj39ss2nUgdsNthsRba2N). Covers NFT staking, SMORES reward accrual, swap pools, and on-chain store products / user credits.
Built on Anchor v0.29.
Install
pnpm add @mallow-labs/mallow-rewards-sdkUsage
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import { Connection, PublicKey } from "@solana/web3.js";
import { MallowRewards } from "@mallow-labs/mallow-rewards-sdk";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const provider = new AnchorProvider(connection, wallet as Wallet, {});
const client = new MallowRewards.Client(provider);
// Stake an NFT to start accruing SMORES
const sig = await client.methods.stake({
nftMint: new PublicKey("..."),
});
// Read accumulated rewards for a user
const userRewards = await client.accounts.userRewards(user.publicKey);
console.log(userRewards?.pointsAccrued.toString());
// Buy a store product with user credits
await client.methods.buyStoreProduct({
storeAuthority,
sku: "merch.hoodie.xl",
});See src/mallowRewards/index.ts for the full public surface and program IDL for account/instruction definitions.
Exports
| Group | Symbols |
|---|---|
| Client | MallowRewards.Client — wraps Anchor Program + Instructions + Methods + Accounts + Pdas |
| Program constants | PROGRAM_ADDRESS, STORE_PROCEEDS_ADDRESS, SMORES_MINT_ADDRESS, XNU_MINT, MALLOW_MONKEYS_MINT_ADDRESS, XEANUS_COLLABS_MINT_ADDRESS (+ _KEY variants and _DEV devnet variants) |
| Instructions | stake, unstake, claimRewards, addRewards, swap, createSwapPool, initStore, updateStore, initStoreProduct, updateStoreProduct, buyStoreProduct |
| Accounts | RewardsConfig, NftStake, UserRewards, SwapPool, Store, StoreProduct, UserCredits |
| PDA helpers | Pdas.rewardsConfig, Pdas.nftStake, Pdas.userRewards, Pdas.swapPool, Pdas.store, Pdas.storeProduct, Pdas.userCredits |
| SKU/URI | getSkuByteArray, getSkuFromByteArray, getUriByteArray, getUriFromByteArray, getCategoryFromSku, getCategoryFromSkuByteArray |
| Constants | MAX_SKU_LENGTH (32), MAX_URI_LENGTH (200) |
SKU format
SKUs are dot-separated: {category}.{name}.{variant}, e.g. merch.hoodie.xl. Stored on-chain as a fixed 32-byte null-padded array.
License
MIT
