Skip to content

Instantly share code, notes, and snippets.

@deanmlittle
deanmlittle / jupiter.rs
Created January 17, 2024 01:52
Jupiter swap lib
use anchor_lang::{prelude::*, Discriminator};
pub mod jupiter {
use super::*;
declare_id!("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
#[derive(AnchorDeserialize, AnchorSerialize)]
pub struct SharedAccountsRoute {
pub id: u8,
pub route_plan: Vec<RoutePlanStep>,
pub in_amount: u64,
@deanmlittle
deanmlittle / anchor-setup.ts
Created November 30, 2023 15:33
Anchor setup with airdrop and log/confirm functions
const program = anchor.workspace.AnchorVault as Program<AnchorVault>;
const connection = anchor.getProvider().connection;
const signer = Keypair.generate();
const vault = PublicKey.findProgramAddressSync([Buffer.from("vault"), signer.publicKey.toBuffer()], program.programId)[0];
const confirm = async (signature: string): Promise<string> => {
const block = await connection.getLatestBlockhash();
@deanmlittle
deanmlittle / Readme.md
Last active March 19, 2024 14:32
Metaplex validator

How to setup :

  1. Create a valid8 folder in your path: mkdir ~/.local/share/valid8

  2. Dump the metaplex program there: solana program dump -u m metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s ~/.local/share/valid8/metadata.so

  3. Create bash script with sudo nano /usr/local/bin/metaplex-test-validator then paste in the following code and save: (if the /user/local/bin directory doesn't exist, you can create it using sudo mkdir -p -m 775 /usr/local/bin)

#!/bin/bash
@deanmlittle
deanmlittle / lib.rs
Last active August 24, 2023 01:24
Anchor hash-based social content ranking
use anchor_lang::prelude::*;
// This is your program's public key and it will update
// automatically when you build the project.
declare_id!("HL1HGm4o5ygkrMYcyS3WYLK3XXPVLyvp9bPksHQZUeWb");
#[program]
mod hello_anchor {
use super::*;
pub fn initialize(ctx: Context<Initialize>, _hash: Vec<u8>) -> Result<()> {
@deanmlittle
deanmlittle / lib.rs
Created May 17, 2023 14:46
Anchor counter increment
use anchor_lang::prelude::*;
// This is your program's public key and it will update
// automatically when you build the project.
declare_id!("HAcYnZCEXGs31qKPXEJUEjPDBnxSLLL2CxSqp4zrpHze");
#[program]
mod plus_one {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
@deanmlittle
deanmlittle / mapi.md
Last active May 9, 2022 22:42
Why mAPI is shit

A far from exhaustive list of reasons why mAPI is shit

  1. While it's an acceptable bandaid for now, we probably shouldn't just wrap JSON-RPC. It's really slow, and there's no reason to run an HTTP server that accesses another HTTP server. It's pretty silly tbh.
  2. Nobody likes C#. Like, nobody.
  3. You shouldn't have to go and install an entire postgres database in parallel to a mining node (both of which just love to compete with eachother to consume maximum resources) just to offer people different fee rates. If you had to do something like this, SQLite would be a much more lightweight alternative, however in almost all cases, miners will probably want to just run their own mining consoles (like any other kind of API service provider would) where they manage all this stuff themselves, so in reality, a simple JWT with an exp field, a fee field and a signing secret without any kind of user management whatsoever is probably already sufficient. If you have strong opinions to the contrary about thi
@deanmlittle
deanmlittle / single_acp.bcs
Created March 7, 2022 12:13
SINGLE|ANYONECANPAY script
OP_1 44 OP_NUM2BIN OP_SWAP OP_CAT 01510905000000000000ffffffffbf643fc069fda04bccfeebfa8803c1d6dc1f28c63dcf6f3421f115a4c801ed0900000000c3000000 OP_CAT OP_HASH256 OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP O
@deanmlittle
deanmlittle / three-scene.component.pug
Last active July 8, 2021 02:38
Angular Threejs scene starter
#rendererContainer(#rendererContainer)
@deanmlittle
deanmlittle / useful-bitcoin-tools.md
Last active December 25, 2022 03:36
Useful Bitcoin Tools
@deanmlittle
deanmlittle / reverse_endianness.forth
Created March 17, 2020 04:16
Reverse the endianness of a SHA256 hash in Bitcoin script
OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT