Hype.fun SDK - v2.0.0

Hype.watch SDK

TypeScript SDK for interacting with Hype.watch's Solana smart contract. This SDK provides functionality for minting and burning Hype tokens, as well as managing client data on the Solana blockchain.

Features

  • Mint Hype tokens
  • Burn Hype tokens
  • Manage client data
  • View root account information
  • Track token transactions and events

Prerequisites

  • Node.js
  • Solana web3.js
  • A Solana wallet and Solana RPC endpoint

Supported Network IDs

The following table outlines the supported networkIds and their corresponding social networks:

Network ID Social Network
0 X
1 Telegram
2 Instagram
3 Facebook

These parameters are subject to change without prior notice. Always the with the root account information.

Usage

Initialize Connection

import { Connection, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
import * as sdk from '../../sdk';

const connection = new Connection("YOUR_SOLANA_ENDPOINT", "confirmed"); // e.g., https://api.devnet.solana.com/
const programId = new PublicKey("HYPE_PROGRAM_ID"); // e.g., Devnet: 5k9VtrtQZWu56qz41cZJmQJTr1CGuSQZE2EEJT77PZUg

Mint Tokens

// Get mint instruction
const mintConfig = await sdk.mint({
wallet: walletPublicKey, // Solana wallet address
rootAccount: rootAccountAddress, // Root account address
root: rootAccountInstance, // Instance of the root account
amount: tokenAmount, // Amount to mint (e.g., 1 token = 1)
programId: programId, // Program ID (e.g., 5k9VtrtQZWu56qz41cZJmQJTr1CGuSQZE2EEJT77PZUg)
connection: connection, // Connection to the Solana cluster
networkId: networkId, // Network ID (0 = Twitter, 1 = Telegram, 2 = Facebook, 3 = Instagram)
address: socialNetworkAddress, // Token mint address (e.g., durov, elonmusk)
nickname: optionalNickname, // Optional nickname
limit: optionalLimit // Optional limit for slippage
});

// Send transaction using Solana web3.js
const transaction = new Transaction().add(mintConfig.instruction);
const signature = await sendAndConfirmTransaction(
connection,
transaction,
[keypair, ...mintConfig.signers]
);

Burn Tokens

const burnInstruction = await sdk.burn({
wallet: walletPublicKey, // Solana wallet address
rootAccount: rootAccountAddress, // Root account address
root: rootAccountInstance, // Instance of the root account
amount: tokenAmount, // Amount to burn (e.g., 1 token = 1)
programId: programId, // Program ID (e.g., 5k9VtrtQZWu56qz41cZJmQJTr1CGuSQZE2EEJT77PZUg)
connection: connection, // Connection to the Solana cluster
networkId: networkId, // Network ID (0 = Twitter, 1 = Telegram, 2 = Facebook, 3 = Instagram)
address: socialNetworkAddress, // Token mint address
nickname: optionalNickname, // Optional nickname
limit: optionalLimit // Optional limit for slippage
});

// Send transaction using Solana web3.js
const transaction = new Transaction().add(burnConfig.instruction);
const signature = await sendAndConfirmTransaction(
connection,
transaction,
[keypair, ...burnConfig.signers]
);

Monitor Smart Contract Logs

// Get root account address
const rootAccount = sdk.findRootAccountAddress(programId, version);

// Subscribe to logs
connection.onLogs(
rootAccount,
(logs) => {
// Parse logs using SDK
const reports = sdk.getReports(logs);
console.log('Parsed logs:', reports);
},
'confirmed'
);

View Root Account Information

const rootAccount = sdk.findRootAccountAddress(programId, version); // Find the root account address
const rootAccountInfo = await connection.getAccountInfo(rootAccount); // Get account info
const root = new sdk.RootAccount(); // Create a new instance of RootAccount
root.update(rootAccountInfo.data); // Update the root account with the retrieved data

Current Parameters

These parameters are subject to change without prior notice depending on the deployed environment.

  • Program ID: 5k9VtrtQZWu56qz41cZJmQJTr1CGuSQZE2EEJT77PZUg
  • Version: 2

Examples

The SDK includes several example implementations:

  1. Token Minting
examples/mint-ts/src/index.ts
  1. Token Burning
examples/burn-ts/src/index.ts
  1. Root Account Visualization
examples/print-root-ts/src/index.ts