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.
The following table outlines the supported networkIds and their corresponding social networks:
| Network ID | Social Network |
|---|---|
| 0 | X |
| 1 | Telegram |
| 2 | |
| 3 |
These parameters are subject to change without prior notice. Always the with the root account information.
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
// 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]
);
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]
);
// 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'
);
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
These parameters are subject to change without prior notice depending on the deployed environment.
5k9VtrtQZWu56qz41cZJmQJTr1CGuSQZE2EEJT77PZUg2The SDK includes several example implementations:
examples/mint-ts/src/index.ts
examples/burn-ts/src/index.ts
examples/print-root-ts/src/index.ts