This file contains 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 type {NextApiRequest, NextApiResponse} from 'next'; | |
import {Connection, PublicKey} from '@solana/web3.js'; | |
import {getNodeURL} from '@figment-solana/lib'; | |
import * as borsh from 'borsh'; | |
// The state of a greeting account managed by the hello world program | |
class GreetingAccount { | |
counter = 0; | |
constructor(fields: {counter: number} | undefined = undefined) { | |
if (fields) { |
This file contains 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 { | |
Connection, | |
PublicKey, | |
Keypair, | |
SystemProgram, | |
Transaction, | |
sendAndConfirmTransaction, | |
} from '@solana/web3.js'; | |
import type {NextApiRequest, NextApiResponse} from 'next'; | |
import {getNodeURL} from '@figment-solana/lib'; |
This file contains 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 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( |
This file contains 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 type {NextApiRequest, NextApiResponse} from 'next'; | |
import {getNodeURL} from '@figment-solana/lib'; | |
import { | |
Connection, | |
PublicKey, | |
SystemProgram, | |
Transaction, | |
sendAndConfirmTransaction, | |
} from '@solana/web3.js'; |
This file contains 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 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; |
This file contains 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 {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; |
This file contains 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 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. | |
*/ |
This file contains 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 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; |
This file contains 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
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(); |
This file contains 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
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"); |