Describe the bug:
I am talking about this page: https://www.soldev.app/course/intro-to-writing-data
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 * as web3 from "@solana/web3.js";
import * as dotenv from "dotenv";
import base58 from "bs58"; // not actually used here (neither in the next block), can be removed
import { getKeypairFromEnvironment } from "@solana-developers/node-helpers"
const toPubkey = new PublicKey(suppliedToPubkey); // suppliedToPubkey is nowhere defined. Maybe show an example with a generated pub key here as in the first tutorial
dotenv.config(); // with es module syntax, it's actually better to just import dotenv/config
const senderKeypair = getKeypairFromEnvironment("SECRET_KEY");
const connection = new Connection("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 } = new Keypair()
const senderKeypair = getKeypairFromEnvironment("SECRET_KEY")
const connection = new Connection(clusterApiUrl("devnet"))
console.log(
`✅ Loaded our own keypair, the destination public key, and connected to Solana`,
)
Describe the bug:
I am talking about this page: https://www.soldev.app/course/intro-to-writing-data
In the Lab section, you can find the following code example which I annotated with comments where I think the block could be improved:
This is what I would suggest the code to update to: