Skip to content

Instantly share code, notes, and snippets.

View AlmostEfficient's full-sized avatar

Raza AlmostEfficient

View GitHub Profile
@AlmostEfficient
AlmostEfficient / cli-sdk-quickstart.md
Last active January 18, 2024 08:38
Solana quickstart guides

title: "CLI & SDK quickstart" description: "This quickstart guide will show you how to use the CLI and the SDK to send SOL." keywords:

  • solana cli send transaction
  • send SOL using SDK
  • transfer SOL using CLI
  • set up Solana Javascript SDK
@AlmostEfficient
AlmostEfficient / load.js
Last active April 28, 2024 09:31
Load a Solana keypair from a .env file as a byte array
// "@solana/web3.js": "^1.87.6",
import { Connection, Keypair, clusterApiUrl } from '@solana/web3.js';
import dotenv from 'dotenv';
dotenv.config();
const connection = new Connection(clusterApiUrl('devnet'), 'confirmed');
const payerSecretKey = JSON.parse(process.env.PAYER);
const payer = Keypair.fromSecretKey(Uint8Array.from(payerSecretKey));
@AlmostEfficient
AlmostEfficient / loud.py
Created November 2, 2023 09:47
Getting too loud? This script will tell you
import pyaudio
import numpy as np
import os
import time
import ctypes
from colorama import Fore, Back, init
# Initialize colorama
init(autoreset=True)
@AlmostEfficient
AlmostEfficient / lib.rs
Created July 6, 2023 11:36
Simple native Solana Rust program that echoes back whatever message you send it.
use solana_program::{
account_info::{AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
pubkey::Pubkey,
};
entrypoint!(process_instruction);
@AlmostEfficient
AlmostEfficient / MetadataViewsNFT.cdc
Last active October 11, 2022 14:29
Publicly mintable Flow NFT contract that conforms to the latest standards.
import NonFungibleToken from 0x631e88ae7f1d7c20;
import MetadataViews from 0x631e88ae7f1d7c20;
pub contract CatMoji: NonFungibleToken {
pub var totalSupply: UInt64
pub event ContractInitialized()
pub event Withdraw(id: UInt64, from: Address?)
pub event Deposit(id: UInt64, to: Address?)
// SPDX-License-Identifier: MIT
// Source:
// https://github.com/ensdomains/ens-contracts/blob/master/contracts/ethregistrar/StringUtils.sol
pragma solidity >=0.8.4;
library StringUtils {
/**
* @dev Returns the length of a given string
*
* @param s The string to measure the length of
@AlmostEfficient
AlmostEfficient / getTokenAccounts.ts
Last active November 2, 2021 11:31
Get all Solana token accounts for a given address
// https://docs.solana.com/developing/clients/jsonrpc-api#gettokenaccountsbyowner
import axios from "axios";
async function getTokenAccounts(address: string) {
try {
return new Promise(async (resolve, reject) => {
let data = {
jsonrpc: "2.0",
id: 1,
method: "getProgramAccounts",