Skip to content

Instantly share code, notes, and snippets.

import { wrap as wrapFetch } from "@faremeter/fetch";
import { Keypair, PublicKey, Connection } from "@solana/web3.js";
import { createLocalWallet } from "@faremeter/wallet-solana";
import { createPaymentHandler } from "@faremeter/x-solana-settlement";
import * as fs from "fs";
(async function main() {
const keypair = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(fs.readFileSync(process.env.SOL_KEY_PATH!, "utf-8"))),

Subscriber Program Design Document

Overview

The Subscriber program manages subscription tiers for Switchboard oracle data access. Users burn payment tokens (SWTCH or other configured tokens) to subscribe to different service levels that control data delivery latency, rate limits, and streaming capacity. Each accepted payment token has a configurable multiplier that affects subscription duration.

Program ID

// TBD - Will be generated during deployment
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SwitchboardQuote {
/// Queue pubkey that this oracle quote belongs to
pub queue: [u8; 32],
/// Uses 2-byte (u16) length prefix
pub signatures: SmallVec<OracleSignature, U16Prefix>,
/// Quote header containing the signed slot hash
pub quote_header: PackedQuoteHeader,
/// Array of feed information (max 255)
/// Uses 1-byte (u8) length prefix
-- Function to Get System Info
on get_system_info()
set timestamp to do shell script "date '+%m/%d/%Y %I:%M:%S %p'"
set computerName to do shell script "scutil --get ComputerName"
set currentUser to do shell script "whoami"
return timestamp & " - Computer: " & computerName & " | User: " & currentUser
end get_system_info
-- Function to Send Message (now sends to your custom webhook instead of Telegram directly)
#!/usr/bin/env bun
import { CrossbarClient } from "@switchboard-xyz/common";
import * as fs from 'fs';
import * as crypto from 'crypto';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
interface Arguments {
apiKeyId: string;
@mgild
mgild / devrel.md
Last active October 5, 2025 14:55

Switchboard DevRel Take-Home (Solana)

Assignment 1 — Docs Review (Switchboard)

Review docs.switchboard.xyz and the Switchboard Examples repository.

Prompt

  • Which sections lack clarity, feel incomplete, or are out of order?
  • Propose 3 concrete improvements (titles, placement, code, diagrams, examples).
  • For each, explain why it helps adoption and where it should live in the nav.
@mgild
mgild / range.ts
Created September 29, 2025 03:29
import { OracleJob, CrossbarClient } from "@switchboard-xyz/common";
import * as sb from "@switchboard-xyz/on-demand";
import { Keypair } from "@solana/web3.js";
function getRangeRiskScoreJob(payer: Keypair): OracleJob {
const job = OracleJob.fromObject({
tasks: [
{
httpTask: {
url: "https://api.range.org/v1/risk/address?address=${ADDRESS}&network=solana",
@mgild
mgild / range
Created September 29, 2025 03:29
function getRangeRiskScoreJob(payer: Keypair): OracleJob {
const job = OracleJob.fromObject({
tasks: [
{
httpTask: {
url: "https://api.range.org/v1/risk/address?address=${ADDRESS}&network=solana",
headers: [
{ key: "accept", value: "application/json" },
// placeholder resolved on-oracle by Secrets
{ key: "X-API-KEY", value: "${RANGE_API_KEY}" },
## Queue Data
publicKey A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w
authority 31Sof5r1xi7dfcaz4x9Kuwm8J9ueAdDduMcme59sP8gc
mrEnclavesLen 1
mrEnclaves
mrEnclave-0 0x0000000000000000000000000000000000000000000000000000000000000000
queueSolBalance 4.131500000
queueSwitchBalance 961863551.599331786
## Queue Data
publicKey A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w
authority 31Sof5r1xi7dfcaz4x9Kuwm8J9ueAdDduMcme59sP8gc
mrEnclavesLen 1
mrEnclaves
mrEnclave-0 0x0000000000000000000000000000000000000000000000000000000000000000
queueSolBalance 2.234500000
queueSwitchBalance 961863551.599331786