initial commit

This commit is contained in:
aresastro
2023-05-09 21:40:31 +08:00
commit 240b79e7be
29 changed files with 6451 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import prompt from 'prompt'
import { Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"
//Create a Solana devnet connection to claim 2 devnet SOL tokens
const connection = new Connection("https://api.devnet.solana.com");
(async () => {
// Start our prompt
prompt.start()
// Take in base58 string
console.log('Enter your address and how much SOL to airdrop):');
const { address, sol } = await prompt.get(['address', 'sol']);
const wallet = new PublicKey(address as string);
try {
const txhash = await connection.requestAirdrop(wallet, (LAMPORTS_PER_SOL * parseInt(sol as string)));
console.log(`Success! Check out your TX here:\nhttps://explorer.solana.com/tx/${txhash}?cluster=devnet`);
} catch(e) {
console.error(`Oops, something went wrong: ${e}`)
}
})()

View File

@@ -0,0 +1,15 @@
import bs58 from 'bs58'
import prompt from 'prompt'
(async () => {
// Start our prompt
prompt.start()
// Take in base58 string
console.log('Enter your base58-encoded private key:');
const { privkey } = await prompt.get(['privkey']);
// Decode private key
const wallet = bs58.decode(privkey as string);
// Print out wallet
console.log(`Your wallet file is:\n[${wallet}]`);
})()

View File

@@ -0,0 +1,15 @@
import bs58 from 'bs58'
import prompt from 'prompt'
(async () => {
// Start our prompt
prompt.start()
// Take in base58 string
console.log('Enter your wallet file:');
const { privkey } = await prompt.get(['privkey']);
// Decode private key
const wallet = bs58.encode(Buffer.from(JSON.parse(privkey as string)));
// Print out wallet
console.log(`Your base58-encoded private key is:\n${wallet}`);
})()