Created
October 20, 2025 15:51
-
-
Save mgild/2331daea6ee50db493240235bf174860 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"))), | |
| ); | |
| const connection = new Connection(process.env.RPC_URL!); | |
| // Create wallet from keypair | |
| const wallet = await createLocalWallet("solana", keypair); | |
| // USDC mint address on Solana mainnet | |
| const mint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); | |
| const fetchWithPayer = wrapFetch(fetch, { | |
| handlers: [createPaymentHandler(wallet, mint)] | |
| }); | |
| const paywalled_rpc_url = "https://helius.api.corbits.dev"; | |
| const response = await fetchWithPayer(paywalled_rpc_url, { | |
| method: "POST", | |
| body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getBlockHeight" }) | |
| }); | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment