Skip to content

Instantly share code, notes, and snippets.

/**
* Function that converts a Rust enum to a string.
* Example rust: { switchboard: {} } -> ts: Switchboard
* @param value Rust enum value
*/
public static convertRustEnumValueToString(value: any) {
// get the key of the enum
let key = Object.keys(value)[0];
// capitalize first letter
key = key.charAt(0).toUpperCase() + key.slice(1);
import MerkleDistributor from '@jup-ag/merkle-distributor-sdk';
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
/**
* MerkleClaimChecker is a class that can be used to check if an address has already claimed a Merkle airdrop.
* Example usage:
* const merkleClaimChecker = MerkleClaimChecker.create()
* .setRpcUrl(rpcConnectionUrl)
* .setDefaultWallet()
@zhe-t
zhe-t / sendTxWithJito.ts
Last active November 27, 2024 11:57
Smart send a transaction using Jito dedicated endpoint
import { Connection, SendOptions } from '@solana/web3.js';
export type JitoRegion = 'mainnet' | 'amsterdam' | 'frankfurt' | 'ny' | 'tokyo';
export const JitoEndpoints = {
mainnet: 'https://mainnet.block-engine.jito.wtf/api/v1/transactions',
amsterdam: 'https://amsterdam.mainnet.block-engine.jito.wtf/api/v1/transactions',
frankfurt: 'https://frankfurt.mainnet.block-engine.jito.wtf/api/v1/transactions',
ny: 'https://ny.mainnet.block-engine.jito.wtf/api/v1/transactions',
tokyo: 'https://tokyo.mainnet.block-engine.jito.wtf/api/v1/transactions',
};
export function getJitoEndpoint(region: JitoRegion) {
@zhe-t
zhe-t / saros.json
Created March 30, 2024 17:49
Saros Airdrop Data
This file has been truncated, but you can view the full file.
[
{
"Address": "AeEezz9Gz6aDKfT1j4Zjn5BUV3CdwRNZDS1DdiE2RKEw",
"Amount": 500000
},
{
"Address": "3gg1jbrxUqhEPBxV6pB4GkLJzjLsmdRQT4qUFXXQLQyS",
"Amount": 500000
},
{
@zhe-t
zhe-t / helper.ts
Last active March 9, 2024 20:23
Reserve lookup address for .sol domains
import fetch from "node-fetch";
export interface DomainLookupResponse {
s: string;
result: {
key: string;
domain: string;
}[];
}
export async function getDomainFromAddress(address: string): Promise<string | null> {
const url = `https://sns-sdk-proxy.bonfida.workers.dev/domains/${address}`;
recipient quantity
8J764UPFVcXtjFcXwnT8gpMYA7kBrKCHruEusczDYRvu 150
Cq75c8JyWbUqcb9uAVtkM8vUJ5L8qMe8gdhEYyk9GCKF 122
9g5tovmmBNZrRZqHK4i5PjxELp1xRWpZWJB9h3j4aUnB 101
BdtiQMAL3mpvbvGncmdtakFERCf8dng9eTnY2MGgRngY 81
2VqSoU8H3ByTzYiyDG8ZTazcDGimJ52hdVbmE1gvLQa2 81
GhuBeitd7eh8KwCurXy1tFCRxGphpVxa8X4rUX8dQxHc 71
DjXKETEYzkkG6YzegWgy78vpaPH1eBxaiGTVoQrkQNFP 70
HAwiWQnFY4vuEfWaZbF6LAvLuGUsrk5mtdQF8rDNYh3b 70
67HB1DLUttZdbTdmiNhY4ehcr6WCs6PdHH6Y9dr6es39 67
@zhe-t
zhe-t / CommonAdapterResponse.ts
Created January 8, 2024 15:27
Common adapter response type for SAC
export interface AdapterResponse {
// User's address
address: string;
// Number of tokens, should already be scaled for UI display
tokens: number;
// Whether the user is eligible (we can calculate based on tokens if not available)
isEligible: boolean;
This file has been truncated, but you can view the full file.
[
{
"wallet": "457pyVt8SvR9aa2nvGBguE1maxczcJHHh2oAYgVkXGSX",
"holder_type": "wallet",
"hxro": 400
},
{
"wallet": "AC5RDfQFmDS1deWZos921JfqscXdByf8BKHs5ACWjtW2",
"holder_type": "wallet",
"hxro": 400
@zhe-t
zhe-t / gist:7d8631e27989a5cd8923be018597b1aa
Created December 14, 2023 00:11
Degen Dolphin Business Holders
CccUdXroFH81QMLpB9HeGBcLXEYx7fNDfJ4ePcCWJFVF,217
4zdNGgAtFsW1cQgHqkiWyRsxaAgxrSRRynnuunxzjxue,192
1BWutmTvYPwDtmw9abTkS4Ssr8no61spGAvW1X6NDix,64
7vBHS6d5bbUxYhTTcdsmXkCbcsobwmN7ZqTBVTHk6wvP,54
12yhqBK95GENSocv83WHojvrKWdxJzJWRE5riXDq1eV5,41
2MnmpzX213VVApFdHBiQLQRpjYiCjHVvewmz8rENYA3q,38
7iPoDrXP8hFAJgCheLV7AFHrgmAHj8Fgh1VTgZyeeJs6,37
DY9B65fruzWe1wQLGsy3JHLaFBikvSfKjEnWTMaf5wJh,36
6wv6uc1TQDsTPBDrQnomcVpabi7SVRXZ2XaQmWWnjM5E,33
9cLPCaR1Z9tDdqv5SxAVHsVRJY8HYgJXi2sDtijNqYzV,23
@zhe-t
zhe-t / gist:3f0b3b5f084b74230cbc332872f58bbc
Created December 13, 2023 23:46
Fetch Helius data in Typescript
export interface AssetResults {
totalResults: number;
results: any[];
}
async function getAssetsByGroup({
creatorAddress,
apiKey
}: {
creatorAddress: string;