Skip to content

Instantly share code, notes, and snippets.

View topherPedersen's full-sized avatar
💭
Rolling my katamari ball

Christopher Pedersen topherPedersen

💭
Rolling my katamari ball
View GitHub Profile
@topherPedersen
topherPedersen / greeter.ts
Last active March 5, 2023 09:03
Solana 101: Storing Data on the Solana Blockchain (From Figment.io's Solana 101 Course)
import {
Connection,
PublicKey,
Keypair,
SystemProgram,
Transaction,
sendAndConfirmTransaction,
} from '@solana/web3.js';
import type {NextApiRequest, NextApiResponse} from 'next';
import {getNodeURL} from '@figment-solana/lib';
@topherPedersen
topherPedersen / deploy.ts
Created January 14, 2022 02:35
Solana 101: Check Deployed Solana Program from Client (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {Connection, PublicKey} from '@solana/web3.js';
import {getNodeURL} from '@figment-solana/lib';
import path from 'path';
import fs from 'mz/fs';
const PROGRAM_PATH = path.resolve('dist/solana/program');
const PROGRAM_SO_PATH = path.join(PROGRAM_PATH, 'helloworld.so');
export default async function deploy(
@topherPedersen
topherPedersen / transfer.ts
Created January 14, 2022 02:05
Solana 101: Transfering Funds (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {getNodeURL} from '@figment-solana/lib';
import {
Connection,
PublicKey,
SystemProgram,
Transaction,
sendAndConfirmTransaction,
} from '@solana/web3.js';
@topherPedersen
topherPedersen / balance.ts
Created January 14, 2022 02:00
Solana 101: Getting Your Balance (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {Connection, PublicKey} from '@solana/web3.js';
import {getNodeURL} from '@figment-solana/lib';
export default async function balance(
req: NextApiRequest,
res: NextApiResponse<string | number>,
) {
try {
const {network, address} = req.body;
@topherPedersen
topherPedersen / fund.ts
Created January 14, 2022 01:57
Solana 101: Funding Your Solana Account via Airdrop (From Figment.io's Solana 101 Course)
import {Connection, PublicKey, LAMPORTS_PER_SOL} from '@solana/web3.js';
import type {NextApiRequest, NextApiResponse} from 'next';
import {getNodeURL} from '@figment-solana/lib';
export default async function fund(
req: NextApiRequest,
res: NextApiResponse<string>,
) {
try {
const {network, address} = req.body;
@topherPedersen
topherPedersen / keypair.ts
Created January 14, 2022 01:53
Solana 101: Creating Solana Accounts AKA Keypair (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {Keypair} from '@solana/web3.js';
/*
* Like with most Web 3 protocols, transactions on Solana happen between accounts.
* To create an account, a client generates a keypair which has a public key (or
* address, used to identify and lookup an account) and a secret key used to sign
* transactions.
*/
@topherPedersen
topherPedersen / connect.ts
Created January 14, 2022 01:48
Solana 101: Connect to Solana (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {getNodeURL} from '@figment-solana/lib';
import {Connection} from '@solana/web3.js';
export default async function connect(
req: NextApiRequest,
res: NextApiResponse<string>,
) {
try {
const {network} = req.body;
@topherPedersen
topherPedersen / main.rs
Created January 13, 2022 04:10
Magic 8 Ball in Rust (Small Example for Learning Rust)
use std::io;
use rand::Rng;
fn main() {
println!("Welcome to Magic 8-Ball");
loop {
println!("What is your question?");
let mut question = String::new();
@topherPedersen
topherPedersen / main.rs
Last active January 13, 2022 01:12
Number Guessing Game in Rust (From the Official Rust Lang Book)
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
loop {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("Guess the number");
@topherPedersen
topherPedersen / verticallyAndHorizontallyCenterH1.js
Created October 23, 2021 17:15
Vertically & Horizontally Center h1 Tag
export default function Home() {
return(
<div
style={{
position: 'absolute',
display: 'flex',
alignItems: 'center',
height: '100%',
width: '100%',
top: 0,