initial commit
This commit is contained in:
21
ts/tools/airdrop_to_wallet.ts
Normal file
21
ts/tools/airdrop_to_wallet.ts
Normal 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}`)
|
||||
}
|
||||
})()
|
||||
15
ts/tools/base58_to_wallet.ts
Normal file
15
ts/tools/base58_to_wallet.ts
Normal 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}]`);
|
||||
})()
|
||||
15
ts/tools/wallet_to_base58.ts
Normal file
15
ts/tools/wallet_to_base58.ts
Normal 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}`);
|
||||
})()
|
||||
Reference in New Issue
Block a user