You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
In the Lab section, you can find the following code example which I annotated with comments where I think the block could be improved:
import*asweb3from"@solana/web3.js";import*asdotenvfrom"dotenv";importbase58from"bs58";// not actually used here (neither in the next block), can be removedimport{getKeypairFromEnvironment}from"@solana-developers/node-helpers"consttoPubkey=newPublicKey(suppliedToPubkey);// suppliedToPubkey is nowhere defined. Maybe show an example with a generated pub key here as in the first tutorialdotenv.config();// with es module syntax, it's actually better to just import dotenv/configconstsenderKeypair=getKeypairFromEnvironment("SECRET_KEY");constconnection=newConnection("https://api.devnet.solana.com","confirmed");console.log(`✅ Loaded our own keypair, the destination public key, and connected to Solana`);
This is what I would suggest the code to update to:
import"dotenv/config"import{Connection,clusterApiUrl,Keypair}from"@solana/web3.js"import{getKeypairFromEnvironment}from"@solana-developers/node-helpers"const{publicKey: toPubkey}=newKeypair()constsenderKeypair=getKeypairFromEnvironment("SECRET_KEY")constconnection=newConnection(clusterApiUrl("devnet"))console.log(`✅ Loaded our own keypair, the destination public key, and connected to Solana`,)