proof-of-take-sdk
v5.0.61
Published
TypeScript SDK for Proof of Take Solana program
Maintainers
Readme
Proof of Miztake SDK
TypeScript/JavaScript SDK for interacting with the Proof of Miztake Solana program.
Installation
npm install @proof-of-miztake/sdk
# or
yarn add @proof-of-miztake/sdkQuick Start
import { AnchorProvider, Program } from "@coral-xyz/anchor";
import { Connection, Keypair } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import {
createMiztake,
claimReward,
depositTokens,
initializeStatistics,
PROGRAM_ID
} from "@proof-of-miztake/sdk";
// Setup
const connection = new Connection("https://api.mainnet-beta.solana.com");
const wallet = // your wallet
const provider = new AnchorProvider(connection, wallet, {});
const idl = // load your IDL
const program = new Program(idl, provider);
// Create a miztake
const tx = await createMiztake(program, {
telegramId: new BN(12345678),
telegramUsername: "myusername",
perceptualHash: "hash1",
averageHash: "hash2",
differenceHash: "hash3",
waveletHash: "hash4",
shaHash: "sha256_hash_must_be_at_least_32_characters_long",
computedAt: new Date().toISOString()
}, wallet.publicKey);
console.log("Miztake created:", tx);API Reference
User Operations
createMiztake()
Create a new miztake with metadata and hashes.
await createMiztake(program, {
telegramId: new BN(12345678),
telegramUsername: "username",
perceptualHash: "hash1",
averageHash: "hash2",
differenceHash: "hash3",
waveletHash: "hash4",
shaHash: "sha256_hash_32_chars_minimum...",
computedAt: "2025-10-26T12:00:00Z"
}, userWallet.publicKey);Parameters:
telegramId: User's Telegram IDtelegramUsername: Max 21 charactersshaHash: Min 32 characters (used for PDA)- Other hashes and metadata
Fee: Dynamic (default 0.0001 SOL)
claimReward()
Claim MIZD token rewards (requires user + admin signatures).
await claimReward(program, {
miztakePda: miztakeAddress,
userTokenAccount: userMizdTokenAccount,
amount: new BN(100_000_000) // 10 tokens with 7 decimals
}, userWallet, adminWallet);Requires:
- User signature (miztake owner)
- Admin signature
- Amount within max_claimable limit
canClaim()
Check if a claim is possible before attempting.
const result = await canClaim(program, miztakePda, new BN(100_000_000));
if (result.canClaim) {
console.log("Can claim! Remaining:", result.remainingClaimable);
} else {
console.log("Cannot claim:", result.reason);
}Token Operations
depositTokens()
Deposit MIZD tokens to the vault (anyone can deposit).
await depositTokens(program, {
amount: new BN(1_000_000_000_000), // 100,000 tokens
depositorTokenAccount: depositorMizdAccount
}, depositorWallet);getVaultBalance()
Get current vault balance.
const balance = await getVaultBalance(program);
console.log("Vault balance:", balance.toString());Admin Operations
initializeStatistics()
Initialize the program (admin only, one-time).
await initializeStatistics(program, adminWallet);updateConfig()
Update program configuration (admin only).
// Update fee
await updateConfig(program, {
newFee: new BN(150_000) // 0.00015 SOL
}, adminWallet);
// Update max claimable
await updateConfig(program, {
newDefaultMaxClaimable: new BN(20_000_000_000) // 2000 tokens
}, adminWallet);
// Update multiple fields
await updateConfig(program, {
newFee: new BN(200_000),
newFeeRecipient: new PublicKey("..."),
newDefaultMaxClaimable: new BN(50_000_000_000)
}, adminWallet);togglePause()
Emergency pause/unpause (admin only).
await togglePause(program, adminWallet);
// Check status
const isPaused = await isProgramPaused(program);withdrawTokens()
Withdraw from vault (admin only).
await withdrawTokens(program, {
amount: new BN(500_000_000_000),
adminTokenAccount: adminMizdAccount
}, adminWallet);Utility Functions
PDA Derivation
import {
getMiztakeStatisticsPda,
getTokenVaultPda,
getUserStatsPda,
getMiztakePda
} from "@proof-of-miztake/sdk";
// Get statistics PDA
const [statisticsPda, bump] = getMiztakeStatisticsPda();
// Get user stats PDA
const [userStatsPda] = getUserStatsPda(new BN(telegramId));
// Get miztake PDA
const [miztakePda] = getMiztakePda(shaHash);
// Get vault PDA
const [vaultPda] = getTokenVaultPda();Query Functions
// Check if initialized
const initialized = await isInitialized(program);
// Get configuration
const config = await getConfig(program);
console.log("Current fee:", config.fee.toString());
console.log("Fee recipient:", config.feeRecipient.toBase58());
console.log("Default max claimable:", config.defaultMaxClaimable.toString());
console.log("Is paused:", config.isPaused);
// Check pause status
const paused = await isProgramPaused(program);Constants
import {
PROGRAM_ID,
ADMIN_PUBLIC_KEY,
MIZD_TOKEN_MINT,
DEFAULT_FEE_RECIPIENT,
DEFAULT_MIZTAKE_FEE,
DEFAULT_MAX_CLAIMABLE,
MIN_FEE,
MAX_FEE,
MAX_USERNAME_LENGTH,
MIN_HASH_LENGTH
} from "@proof-of-miztake/sdk";Types
All TypeScript types are exported:
import {
CreateMiztakeParams,
ClaimRewardParams,
DepositTokensParams,
WithdrawTokensParams,
UpdateConfigParams,
MiztakeStatistics,
UserStats,
Miztake
} from "@proof-of-miztake/sdk";Error Handling
try {
await createMiztake(program, params, wallet.publicKey);
} catch (error) {
if (error.message.includes("UsernameTooLong")) {
console.error("Username exceeds 21 characters");
} else if (error.message.includes("ProgramPaused")) {
console.error("Program is currently paused");
} else if (error.message.includes("InvalidHashLength")) {
console.error("SHA hash must be at least 32 characters");
}
// Handle other errors...
}Examples
Complete Flow Example
import { Program, BN } from "@coral-xyz/anchor";
import {
createMiztake,
depositTokens,
claimReward,
getMiztakePda,
PROGRAM_ID
} from "@proof-of-miztake/sdk";
// 1. Deposit tokens to vault (admin)
await depositTokens(program, {
amount: new BN(10_000_000_000_000), // 1M tokens
depositorTokenAccount: adminMizdAccount
}, adminWallet);
// 2. User creates miztake
const miztakeParams = {
telegramId: new BN(12345678),
telegramUsername: "cryptouser",
perceptualHash: "abc123...",
averageHash: "def456...",
differenceHash: "ghi789...",
waveletHash: "jkl012...",
shaHash: "sha256_hash_exactly_32_chars_min",
computedAt: new Date().toISOString()
};
await createMiztake(program, miztakeParams, userWallet.publicKey);
// 3. Admin + User claim reward
const [miztakePda] = getMiztakePda(miztakeParams.shaHash);
await claimReward(program, {
miztakePda,
userTokenAccount: userMizdAccount,
amount: new BN(100_000_000) // 10 tokens
}, userWallet, adminWallet);Launchpad Integration (Moonpool/Sunpool)
For bot developers integrating the launchpad functionality with automatic keypair generation, see the comprehensive guide:
📘 LAUNCHPAD_BOT_INTEGRATION.md
Quick Example
import { joinSeason } from "@proof-of-miztake/sdk";
import { BN } from "@coral-xyz/anchor";
// Call joinSeason with launchpad mode
const result = await joinSeason({
connection,
user: userPublicKey,
seasonNumber: new BN(1),
tier: 4,
launchpad: true, // Enable launchpad mode
});
// ✅ CRITICAL: Extract and use the auto-generated keypair
const signers = [adminWallet, userWallet];
if (result.meta?.launchpadTokenMintKeypair) {
signers.push(result.meta.launchpadTokenMintKeypair);
console.log("Added launchpad mint keypair");
}
// Sign and send transaction with all signers
tx.sign(...signers);Important: The SDK auto-generates the launchpad mint keypair, but your bot must extract it from result.meta.launchpadTokenMintKeypair and include it when signing the transaction. See the full guide for details.
Building from Source
# Clone and install
git clone ...
cd proof_of_miztake_library
npm install
# Build
npm run build
# The dist/ folder contains the compiled JavaScriptLicense
MIT
Support
For issues and questions:
- GitHub: [Your repo]
- Documentation: See project README
- Security: See SECURITY_AUDIT.md
